溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Cordova學(xué)習(xí)筆記   angular http請求

發(fā)布時間:2020-06-22 10:26:32 來源:網(wǎng)絡(luò) 閱讀:451 作者:hello_world007 欄目:開發(fā)技術(shù)
<!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 應(yīng)用程序 的"所有者"-->
        <div>
            name:<input name="name" ng-model="name"/> <!--ng-model 指令把輸入域的值綁定到應(yīng)用程序變量 name-->
        </div>
        <div ng-bind="name"></div><!--指令把應(yīng)用程序變量 name 綁定到某個段落的 innerHTML。-->
        `name`<!--這里與上面的model建立了數(shù)據(jù)雙向綁定  {{}}等同于 ng_bind-->
        <div ng-init="sex='f';age='23';person={name:'李三'};number=[5,6];"> <!--指令為 AngularJS 應(yīng)用程序定義了 初始值 等價于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"><!--定義了應(yīng)用程序控制器-->
            title:<input name="title" ng-model="title"><!--我們可以把我們的 model 存放在 scope 上,來達到雙向你綁定-->
            `title`
        </div>
        <div ng-controller="secondCtl">
            <ul>
                <li ng-repeat="n in numbs"> <!--ng-repeat 是一個循環(huán)指令-->
                    `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 是控制器所指向的應(yīng)用程序 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} – 服務(wù)器返回的數(shù)據(jù)
                 status – {number} – 響應(yīng)的 HTTP 狀態(tài)碼 .
                 headers – {function([headerName])} – Header getter function.
                 config – {Object} – The configuration object that was used to generate the request.
                 statusText – {string} – 響應(yīng)的 HTTP 狀態(tài)文件本.
                 */
                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>


向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI