(六)使用angular.bootstrap完成模組的手動載入,angularbootstrap
之前我們看到使用ng-app指令,可以實現模組的自動載入。現在我們看下,angular中如何手動載入模組。需要使用到angular.bootstrap這個函數。
<html><head><script src="angular.js"></script><script> // 建立moudle1var rootMoudle = angular.module('moudle1', []);rootMoudle.controller("controller1",function($scope){$scope.name="aty"});// 建立moudle2var 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>
IE運行這個網頁,發現變數能夠被angular架構正確解析;F12發現控制台也沒有報錯誤。到這裡為止,我們知道了如何載入angular的模組,也明白了手動載入和自動載入的區別。接下來,我們就可以去繼續學習angularjs架構的其他知識。
怎讓bootstrap不對模組地區裡的內容載入樣式?
那你在模組地區內容單獨設定css樣式,這樣就可以把bootstrap的樣式覆蓋了
ZF怎載入模組各自的Bootstrapphp - PHP架構開發
resources下面添加這幾個:[ol][*]? ? \'frontController\' => array ([*]? ?? ?\'moduleDirectory\' => APPLICATION_PATH.\'/modules/\',[*]? ?? ?\'moduleControllerDirectoryName\' => \'controllers\',[*]? ?? ?\'defaultModule\' => \'default\'[*]? ? ),[*]? ? \'modules\' => array (\'default,admin\'),[/ol]