1

I have an AngularJS document where I need to set fields in various parts of the document. This includes e.x. the <title> tag. So my document Looks like the following:

<html ng-app="test" ng-controller="TestCtrl">
    <head>
        <title>{{test1}}</title>
    </head>
    <body>
        <h1>{{test1}}</h1>
        ...
    </body>
</html>

As you can see I put the ng-controller in the <html> tag because I need to use the same scope across <head> and <body>. I could also set the controller on the individual elements but since I'm doing some POST and GET queries I think it's not a good idea because then they are performed multiple times.

Is using the ng-controller tag in the <html> element a good idea (is there a negative impact)? Are there better solutions?

lin
  • 17,956
  • 4
  • 59
  • 83
Thomas Sparber
  • 2,827
  • 2
  • 18
  • 34
  • 2
    Possible duplicate of [Is it bad to declare ng-app and ng-controller on html tag?](http://stackoverflow.com/questions/19254400/is-it-bad-to-declare-ng-app-and-ng-controller-on-html-tag) – Ben Kauer Nov 25 '15 at 10:09
  • 1
    you can use highest vote answer of this post also. http://stackoverflow.com/questions/12506329/how-to-dynamically-change-header-based-on-angularjs-partial-view – Partha Sarathi Ghosh Nov 25 '15 at 10:19

0 Answers0