溫馨提示×

溫馨提示×

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

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

AngularJS如何使用angular.bootstrap完成模塊手動加載

發布時間:2021-07-10 18:27:23 來源:億速云 閱讀:175 作者:小新 欄目:web開發

這篇文章主要介紹AngularJS如何使用angular.bootstrap完成模塊手動加載,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

本文實例分析了AngularJS使用angular.bootstrap完成模塊手動加載的方法。分享給大家供大家參考,具體如下:

之前我們看到使用ng-app指令,可以實現模塊的自動加載?,F在我們看下,angular中如何手動加載模塊。需要使用到angular.bootstrap這個函數。

<html>
  <head>
    <script src="angular.js"></script>
    <script>
    // 創建moudle1
    var rootMoudle = angular.module('moudle1', []);
    rootMoudle.controller("controller1",function($scope){$scope.name="aty"});
    // 創建moudle2
    var m2 = angular.module('moudle2', []);
    m2.controller("controller2",function($scope){$scope.name="aty"});
    // 頁面加載完成后,再加載模塊
    angular.element(document).ready(function() {
      angular.bootstrap(document.getElementById("div1"),["moudle1"]);
      angular.bootstrap(document.getElementById("div2"),["moudle2"]);
    });
  </script>
  <head>
  <body>
    <div id="div1" ng-controller="controller1">div1:{{name}}</div>
    <div id="div2" ng-controller="controller2">div2:{{name}}</div>
  </body>
</html>

以上是“AngularJS如何使用angular.bootstrap完成模塊手動加載”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女