Angularjs Summary (vii) Routing and request Service, etc.

Source: Internet
Author: User

1define ([' angular '),function(ng) {2' Use strict ';3 4     varApp = Ng.module (' Index-module ', [' ngcookies ', ' ngroute ', ' ui.bootstrap ']);5 6App. Config ([' $routeProvider ',function($routeProvider) {7 $routeProvider8. When ("/", {controller: ' Index-controller ', Templateurl: '/partials/_menu.html ' })9. When ("/manage/case:casenumber", {controller: ' Addcase-controller ', Templateurl: '/partials/_addcase.html ' })Ten. Otherwise ({redirectto: '/phonecase/index ' }); One     }]); A  -     returnapp; -});

1.ng-router:

Get the route parameter (the parameter after the colon):
$routeParams. Casenumber

2. Request a Service
GET Request:
$http ({
Method: ' Get ',
URL: ' http://camnpr.com/getAPI/',
Params:{id:1},
Headers: {"Content-type": "Application/json; Charset=utf-8 "}//can add any header information
});
POST request:
$http ({
Method: ' Post ',
URL: ' http://camnpr.com/postAPI/',
Data: ' id=1&referrer=camnpr.com ',//Here is the string, format please note that at the same time we can use $.param ({id:1, referrer: ' camnpr.com '}) to get the equivalent form.
form data gets the way request.form[' ID '].
This is the credit of adding ' content-type ': ' application/x-www-form-urlencoded '.
If you do not add ' Content-type ', then: Request payload:id=1&referrer=camnpr.com
Data: {id:1, referrer: ' camnpr.com '},//Is the object, then the information for Form data is: {"id": 1, "referrer": "Camnpr.com"}:
Headers: {' content-type ': ' Application/x-www-form-urlencoded;charset=utf-8 '}
});

3. Get HTML elements
<input type= "checkbox" value= "1" class= "Is_select" >
Angular.element ('. Is_select ');
4. Cycle
Angular.foreach (Data,function (item,index) {
});

Angularjs Summary (vii) Routing and request Service, etc.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.