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.