I'm new to Angular Programming, I found a problem about using ocLazyLoad.
First I imported ocLazyLoad to my app. But console occurs these error.
Error: [ng:areq] Argument 'ABController' is not a function, got undefined
How should i do because i need handle some backend data from controller. Suppose the console need to show "123". This is my code.
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"); });
In case i didn't overlook anything: you forgot to include test.js into your index.html...