我刚开始使用角编程,我发现了一个使用ocLazyLoad的问题。
首先,我将ocLazyLoad导入我的应用程序。但是控制台会出现这些错误。
错误: ng:areq参数'ABController‘不是函数,未定义
我应该如何做,因为我需要处理来自控制器的一些后端数据。假设控制台需要显示"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"); });发布于 2015-11-17 15:22:35
如果我没有忽略任何事情:你忘了在你的index.html中加入index.html.
发布于 2016-05-31 16:26:45
试着使用
angular.module("LazyLoadTest").controller('ABController', function($scope){ console.log("123"); });在test.js中
https://stackoverflow.com/questions/33760507
复制相似问题