<!DOCTYPEhtml><html><head><metacharset="utf-8"><metaname="viewport"content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width"><title>test</title></head><body><divng-app="myApp"><!--ang-app指令告诉AngularJS,<div>元素是AngularJS应用程序的"所有者"--><div>name:<inputname="name"ng-model="name"/><!--ng-model指令把输入域的值绑定到应用程序变量name--></div><divng-bind="name"></div><!--指令把应用程序变量name绑定到某个段落的innerHTML。-->`name`<!--这里与上面的model建立了数据双向绑定{{}}等同于ng_bind--><divng-init="sex='f';age='23';person={name:'李三'};number=[5,6];"><!--指令为AngularJS应用程序定义了初始值等价于data-ng-init-->`sex`,`age`</div><div>`sex`,`age`</div><div>`person`.`name`;{{number[0]}}+6={{5+6}},{{'对'+'的'+age}}<!--表达式很像JavaScript表达式:它们可以包含文字、运算符和变量--></div><divng-controller="firstCtl"><!--定义了应用程序控制器-->title:<inputname="title"ng-model="title"><!--我们可以把我们的model存放在scope上,来达到双向你绑定-->`title`</div><divng-controller="secondCtl"><ul><ling-repeat="ninnumbs"><!--ng-repeat是一个循环指令-->`n`</li></ul></div></div><scriptsrc="js/angular.js"></script><scripttype="text/javascript">varmyApp=angular.module('myApp',[]);myApp.controller('firstCtl',function($scope){//控制器的$scope是控制器所指向的应用程序HTML元素angular中$scope是连接controllers(控制器)和templates(模板view/视图)的主要胶合体。$scope.title='Hello';});myApp.controller('secondCtl',function($scope,$http){$scope.numbs=[111,222,333,444];$http({method:'GET',url:'http://www.xweb.com/test2.php'}).then(functionsuccessCallback(response){/*response这个对象有如下属性:data–{string|Object}–服务器返回的数据status–{number}–响应的HTTP状态码.headers–{function([headerName])}–Headergetterfunction.config–{Object}–Theconfigurationobjectthatwasusedtogeneratetherequest.statusText–{string}–响应的HTTP状态文件本.*/console.log(response);},functionerrorCallback(response){console.log(response);});$http({method:'POST',url:'http://www.xweb.com/test2.php',data:"test=test22222",headers:{'Content-Type':'application/x-www-form-urlencoded'},}).then(functionsuccessCB(response){console.log(response);},functionerrorCB(response){console.log(response);});$http.post('http://www.xweb.com/test2.php',{'test':'po'},{params:{'te':'te'}}).then(function(response){console.log(response);},function(response){console.log(response);});});</script></body></html>