Cordova学习笔记 http及run方法

发布时间:2020-08-03 10:48:27 作者:hello_world007
来源:网络 阅读:414
<!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>
        `testdata`
    </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.run(['$rootScope',function($rootScope){ //只对全局作用域起作用
            $rootScope.testdata = 'heheh';
        }]);
        myApp.controller('secondCtl', function($scope , $http) {
            $scope.numbs  = [111,222,333,444];
            $http({
                method: 'GET',
                url: 'http://www.test.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.test.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.test.com/test2.php',
                    {'test':'po'},
                    {params:{'te':'te'}}).then(function(response){
                console.log(response);
            },function(response){
                console.log(response);
            });

        });
    </script>

</body>
</html>


推荐阅读:
  1. Nginx学习笔记(一)
  2. Cordova学习笔记 事件的简单使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

学习笔记 cordova un

上一篇:python表示换行符的方法

下一篇:python datetime处理时间的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》