Discussions
oclazyload + angularjs + ngroute + asp.net mvc
I´m developing an application in asp.net mvc with angularjs and I need to lazy load some of my controllers, directives, services and so on. I´ve searched deeply on web and I found this js library to work with.
so let see how my code are:
1 - LayoutPage (ASP.NET MVC)
/all my imports scripts are at the bottom of the page/
2 - app.js
var MyApp = angular.module("myAppUAI", ["ngProgress", "ngMaterial", "ngRoute", "oc.lazyLoad"]);
MyApp.config(["$routeProvider", "$ocLazyLoadProvider"
, function ($routeProvider, $ocLazyLoadProvider) {
$routeProvider
.when("/", {
templateUrl: "/Main/Index",
controller: "progressCircularController",
resolve: {
home: function ($ocLazyLoad) {
return $ocLazyLoad.load(["/Scripts/AngularJS/Controllers/progressCircularController.js"]);
}
}
})
.otherwise({
redirectTo: "/"
});
$ocLazyLoadProvider.config({
debug: true,
events: true
});
}]);
3 - progressCircularController.js
angular.module("myAppUAI").controller("progressCircularController", ["$rootScope", "$scope", function ($rootScope, $scope) {
$scope.key = "Marcelo Bertinatto D´ Onofrio";
}]);
4 - in my view
And finally, I´m getting a error in console like this:
http://errors.angularjs.org/1.6.2/$controller/ctrlreg?p0=progressCircularController
ocLazyLoad.fileLoaded scripts/AngularJS/Controllers/progressCircularController.js
angular.js:14362 ocLazyLoad.componentLoaded ["myAppUAI", "register", "progressCircularController"]
angular.js:14362 ocLazyLoad.moduleReloaded myAppUAI
I've exhausted all my possibilities. Can you tell me what I´m doing wrong?
Thanks in advance.