Cordova學習筆記 http及run方法

來源:互聯網
上載者:User

標籤:cordova

<!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>


Cordova學習筆記 http及run方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.