Akshay
Akshay

Reputation: 51

what is difference between writing ng-app in <html> tag and <body> tag?

we can write ng-app in any html tag.

But what is the difference if we write it in <html> or <body> or <head>.

Please help me out.

Upvotes: 0

Views: 482

Answers (2)

Anik Islam Abhi
Anik Islam Abhi

Reputation: 25352

Wherever you put ng-app it doesn't matter.

ng-app enables angular environment within it's block.

like if you use ng-app in head tag then it'll enable angular environment within it's </head> tag.

Like this

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div>

  <div ng-app>
    {{4+5}} <!-- inside of ng-app block -->
  </div>

  <div>
    {{4+5}} <!-- outside of ng-app block -->
  </div>

</div>

Upvotes: 3

Shujaath Khan
Shujaath Khan

Reputation: 1384

Bootstrapping of your application begins from the element where you declare the attribute

data-ng-app

Upvotes: 0

Related Questions