<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>test</title>
</head>
<body>
    <div ng-app="myApp" ><!--ang-app 指令告诉 AngularJS, <div> 元素是 AngularJS 应用程序 的"所有者"-->
        <div>
            name:<input name="name" ng-model="name"/> <!--ng-model 指令把输入域的值绑定到应用程序变量 name-->
        </div>
        <div ng-bind="name"></div><!--指令把应用程序变量 name 绑定到某个段落的 innerHTML。-->
        `name`<!--这里与上面的model建立了数据双向绑定  {{}}等同于 ng_bind-->
        <div ng-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>

        <div ng-controller="firstCtl"><!--定义了应用程序控制器-->
            title:<input name="title" ng-model="title"><!--我们可以把我们的 model 存放在 scope 上,来达到双向你绑定-->
            `title`
        </div>
        <div ng-controller="secondCtl">
            <ul>
                <li ng-repeat="n in numbs"> <!--ng-repeat 是一个循环指令-->
                    `n`
                </li>
            </ul>
        </div>
    </div>
    <script src="js/angular.js"></script>
    <script type="text/javascript">
        var myApp = 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(function successCallback(response) {
                /*
                 response这个对象有如下属性:
                 data – {string|Object} – 服务器返回的数据
                 status – {number} – 响应的 HTTP 状态码 .
                 headers – {function([headerName])} – Header getter function.
                 config – {Object} – The configuration object that was used to generate the request.
                 statusText – {string} – 响应的 HTTP 状态文件本.
                 */
                console.log(response);
            }, function errorCallback(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(function successCB(response){
                console.log(response);
            },function errorCB(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>