I want to be able to change the background color of depending on what the current path is.
I tried doing it by checking $location.path() wh
I noticed that when I navigate to another page without page reload background color still remains, so I am doing this (I am using angular ui-router):
In config:
$stateProvider.state('app.login',{
url: '/login',
onExit: function($rootScope){
$rootScope.bodyClass = 'body-one';
},
templateUrl: 'ng/templates/auth/login-page-one.html',
controller: function($rootScope){
$rootScope.bodyClass = 'body-two';
}
})
.state('app.signup',{
url: '/signup',
onExit: function($rootScope){
$rootScope.bodyClass = 'body-one';
},
templateUrl: 'ng/templates/auth/signup-page-one.html',
controller: function($rootScope){
$rootScope.bodyClass = 'body-two';
}
});
In the Template
In CSS:
.body-one{
margin-top: 50px;
background: #f0f4fb;
}
.body-two{
margin: 0;
padding: 0;
background: #2e9fff;
}