Reputation: 5762
in my index.html I have my <header>
then <body>
with some subelements and <footer>
elements.
Rest of the code is in template for each page like templates/home.html, templates/login.html
For one of this page I need to replace:
<body class="page-homepage" ng-app="historyApp" id="body">
to
<body class="page-subpage" ng-app="historyApp">
Is there some nice way how to do it?
I find some ways with jquery like (take it as example):
var el = document.querySelector('#body');
el.classList.remove('page-homepage');
el.classList.add('page-subpage');
but I believe that many of you already had to deal with this is kind of problem. Can someone suggest me how to do this in angular?
Upvotes: 2
Views: 323
Reputation: 588
In my opinion, the best way to do this is to add a variable to your $rootScope
$rootScope.isSub = false;
And use ngClass directive on your body element :
<body ng-class="{'page-subpage':isSub,'page-homepage':!isSub}" ng-app="historyApp">
And for each controller specify the $rootScope.isSub value.
Upvotes: 4