angular.bootstrap to run multiple angular apps

后端 未结 1 1646
半阙折子戏
半阙折子戏 2021-01-03 02:31

This is NOT a Twitter Bootstrap question...

I have a use case that requires the loading of separate angular applications.

Based on several s

相关标签:
1条回答
  • 2021-01-03 03:23

    to grab references to your app(s), you can do something along the lines of:

    var first = document.getElementById('firstapp-id');
    var second = document.getElementById('secondapp-id');
    
    angular.bootstrap(angular.element(first), ['firstapp']);
    angular.bootstrap(angular.element(second), ['secondapp']);
    

    where 'firstapp' and 'secondapp' are module/app names, and 'firstapp-id' and 'secondapp-id' are the id's of the container div's for each app (or your favorite DOM element). just define your apps in the usual manner:

    var firstapp = angular.module('firstapp', []);
    var secondapp = angular.module('secondapp', []);
    
    0 讨论(0)
提交回复
热议问题