📎 Webclip
Define multiple Angular apps in one page
The page explains that AngularJS auto-bootstrap via ng-app works only once per HTML document, so if a page has multiple ng-app attributes, only the first one is initialized. It then shows ways to place two Angular apps on the same page by bootstrapping them manually or by using a root app that includes both modules.
Reading notes#
- Only one AngularJS application can be auto-bootstrapped per HTML document.
- If a page has multiple
ng-appattributes, only the first one is considered and the rest are ignored. - One option is to remove
ng-appand bootstrap both apps manually withangular.bootstrap(). - Another option is to keep
ng-appfor the first app and manually bootstrap only the second app. - A third option is to define a root app with
ng-appand inject both apps as modules in that root app.
