Search code examples
javascriptangularjswebng-classangularjs-ng-class

ng-class not updating outside the html


I have used following code in my project. Sorry I won't be able to share any plunker or jsfiddle

    <div class="container full-height" ng-class="{'navmargin': model.showHeaderBasedError}" data-ui-view="main_container"></div>
{{model.showHeaderBasedError}}

enter image description here

enter image description here

enter image description here
As the output state: the variable used outside the html is working perfectly fine but the one used in the Html is not updating.


Solution

  • ng-class is incompatible with ui-view, You could fix this issuse by upgrading angular 1.3.8 and ui-router 0.2.13.

    GitHub Issue Link Here

    Update

    Try ng-attr directive that will help you.

    ng-attr-class="{{model.showHeaderBasedError? 'navmargin': ''}"