How to run two separate Angular js apps in the same page

后端 未结 3 1442
甜味超标
甜味超标 2020-12-05 10:08

New to Angular. I feel like I\'m missing something obvious: Shouldn\'t I easily be able to run to separate AngularJs apps (modules) in the same html page? Something like thi

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 10:18

    You can specify any nested apps in the module def of the main one.

    angular.module("myapp", ['statusapp', 'tickerapp']).controller(....
    

    and in a separate file, you have the other apps defined. We're using a template engine which hides some of this, but you'll end up with HTML that contains nested ng-apps and javascript for each one that defines the module/controller. The code above is the trick to getting more than one bootstrapped.

提交回复
热议问题