<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                AngularJS中為我們提供了眾多的內置服務,通過這些內置服務可以輕松的實現一些常用功能。下面對Angular中常用的內置服務進行一下總結。 1.$location服務 $location服務用于返回當前頁面的URL地址,示例代碼如下: ~~~ var app = angular.module('myApp', []); app.controller('customersCtrl', function($scope, $location) { $scope.myUrl = $location.absUrl(); }); ~~~ 這里為$scope對象定義了myUrl變量,然后利用$location服務讀取到了URL地址并存儲到myUrl中。 2..$http服務 $http 是 AngularJS 中最常用的服務,它經常用于服務器的數據傳輸。下面的例子中服務向服務器發送請求,應用響應服務器傳送過來的數據。 ~~~ var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http) { $http.get("welcome.htm").then(function (response) { $scope.myWelcome = response.data; }); }); ~~~ 3.$timeout()服務和$interval()服務 這兩個服務的功能對應的是javascript中的setTimeout()和setTimeInterval函數。一個簡單的實時更新時間例子如下: ~~~ app.controller('myCtrl', function($scope, $interval) { $scope.theTime = new Date().toLocaleTimeString(); $interval(function () { $scope.theTime = new Date().toLocaleTimeString(); }, 1000); }); ~~~ 除了Angular中提供的內置服務外,我們也可以自己定義服務,利用service即可,下面是一個定義服務的基本代碼框架: ~~~ app.service('hexafy', function() { this.myFunc = function (x) { return x.toString(16); } }); ~~~ 定義好服務后,我們可以像使用內置的Angular服務一樣使用它: ~~~ app.controller('myCtrl', function($scope, hexafy) { $scope.hex = hexafy.myFunc(255); }); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看