xrcwrn
xrcwrn

Reputation: 5327

Angular controller is not working

I have a html pages i have included a header in all html page header contains menu and there i am using a tag

header.jsp

<div class="navbar navbar-default navbar-fixed-top" role="navigation"<ng-app="myApp" ng-controller="headerController">
.....
</div>

and in another html pages I am including this menu like

<html>
<body>
<div id="header">
 <jsp:include page="/pages/common/header.jsp"/>
 </div>
<div class="container" ng-app="myApp" ng-controller="bodyController" >
..............................
</div>
</body>
</html>

This is general structure for all my pages My problem is at a time both controller is not running for any page if header page controller is working then bodyController is not running, when i comment to header controller the body controller works. I am using angular 1.6.5

How to resolve this problem?

Upvotes: 0

Views: 50

Answers (1)

rrd
rrd

Reputation: 5957

I would suggest this:

<body ng-app="myApp">

Then remove the ng-app from everywhere else.

Your header.jsp file has spelling mistakes in it which is why you have the problem, and you have two ng-app's (which is why I suggest putting it in one location, on the body tag).

Upvotes: 1

Related Questions