Add directive to module after bootstrap and applying on dynamic content

后端 未结 2 1829
走了就别回头了
走了就别回头了 2020-12-29 13:21

I have a web page with a module defined (myModule) where I\'m boostraping angularjs using

angular.bootstrap(element,[myModule.name]);

After

2条回答
  •  被撕碎了的回忆
    2020-12-29 14:21

    The thing with registering lazy controller or directives is that you have to get hold of $controllerProvider and $compileProvider respectively.

    It can be done only during configuration phase so you have to keep the references until you load the controllers/directives.

    Lately I was working on lazy loading of the controller, today I've added support for directives, check out my code here:

    https://github.com/matys84pl/angularjs-requirejs-lazy-controllers/

    particularly this module lazy-directives.js

    NOTE: I use RequireJS in my project, however applying my solution to yepnope should be quite easy.

提交回复
热议问题