我是Angular Programming的新手,我發現了一個關於使用ocLazyLoad的問題。ocLazyLoad不加載控制器,如何解決它?
首先,我將ocLazyLoad導入到我的應用程序中。但控制檯發生這些錯誤。
Error: [ng:areq] Argument 'ABController' is not a function, got undefined
我該怎麼做,因爲我需要處理控制器的一些後端數據。假設控制檯需要顯示「123」。這是我的代碼。
的Index.html
<script src="https://code.jquery.com/jquery-1.11.2.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script>
<script src="js/main.js"></script>
<script src="../../dist/ocLazyLoad.js"></script>
<body>
<div id="example" ng-app="LazyLoadTest" ng-controller="TestController">
<div ng-controller="ABController"></div>
</div>
<script>
app.controller("TestController", function($scope, $ocLazyLoad, $compile) {
$ocLazyLoad.load("js/test.js").then(function() {
console.log('loaded!!');
}, function(e) {
console.log('errr');
})
});
</script>
</body>
main.js
var app = angular.module("LazyLoadTest", ["oc.lazyLoad"]);
test.js
app.controller('ABController', function($scope){ console.log("123"); });
哦,THX,僅此而已。 = D – tommychoo
你是認真的嗎?他正在嘗試使用$ ocLazyLoad。如果你將'test.js'加載到你的index.html中,那就好像不使用$ ocLazyLoad – RicardoGonzales