AngularJS Dynamic loading a controller

Re-reading this article http://ify.io/lazy-loading-in-angularjs/ suggested to keep a $contentProvider instance inside Angular App.

I came up with this code in my app.js

demoApp.config(function ($controllerProvider) {
     demoApp.controller = $controllerProvider.register;
});

It enables me to write my controller as expected in a external javascript file :

angular.module("demoApp").controller('MouseTestCtrlA', fn);

Hope this can help !

Leave a Comment