Matt Roberts
Matt Roberts

Reputation: 26877

Making angular app work in IE

Following the instructions here, I can get a simple angularJS app working in IE.

However, I'm struggling with the constraint that you need to add id='ng-app' ng-app='some-module' to the root (html) element. The Docs state:

"add id="ng-app" to the root element in conjunction with ng-app attribute"

<!doctype html> 
    <html xmlns:ng="http://angularjs.org" id="ng-app"
ng-app="optionalModuleName">   
    ... 
    </html>

But how does that work if my app has multiple modules - which is surely the commonplace? In my scenario, I've got a table module that deals with a pagable table control, and I've just created a module to handle displaying country flags.

Does this restriction mean that I can only have a single module (uberModule) with everything defined in there? Seems a bit rubbish, or am I missing something?

Disclaimer: I'm a angular noob so it could be that I'm just doing something very wrong

Upvotes: 0

Views: 1337

Answers (1)

Davin Tryon
Davin Tryon

Reputation: 67296

Typically, there is only a single ng-app on an html document as described in the docs:

Use this directive to auto-bootstrap an application. Only one ngApp directive can be used per HTML document. The directive designates the root of the application and is typically placed at the root of the page.

The first ngApp found in the document will be auto-bootstrapped. To use multiple applications in an HTML document you must manually bootstrap them using angular.bootstrap. Applications cannot be nested.

Of course, if you only have a single ng-app, then there is no problem having a single id attribute set to the value "ng-app".

Although, as mentioned above, you can use bootstrapping to manage multiple ng-app on a page. Since, bootstrapping manually doesn't require an ng-app attribute to be placed on the page, there should be no id attribute issue.

Upvotes: 2

Related Questions