In a simplified scenario, I have two UI-Router interface states , and they need different background colors for the background.
Ideally, I would like to do the following:
<body ng-class="background" ui-view> </body>
and then in the controller for the states background classes are set (which can be dynamic, which means: it is calculated in the controller):
stateHelperProvider .state({ name: 'a', url: '/a', templateUrl: 'views/a.html', controller: function ($scope) { $scope.background = 'bg1'; } }) .state({ name: 'b', url: '/b', templateUrl: 'views/b.html', controller: function ($scope) { $scope.background = 'bg2'; } });
But adding the ui-view attribute to the body removes it. So I have to put the ui-view attribute in a div inside the body.
<body> <div ui-view></div> </body>
How can I control the background of the body now?
I am aware of various hacks (for example, accessing the property of the DOM class of the body in the onEnter UI-Router function, ...), but is there a good way to do this?
Or is it all about making the div[ui-view] full height ( not trivial ) and setting the background on this element to simulate the use of the background on the body occupying the full viewport ?
source share