Search code examples
cssangularjsng-class

Why my ng-class is not working


I am trying to display spinner when the button is clicked. I had one working plunker and I am trying to implement it little bit of tweak. My Plunker is here. I referred this working Plunker but no luck. I know m missing something small here.

ng-class="{true: overlay}[madeCall]"


Solution

  • Ok both answers point correctly one error, but there is also a fault in logic.

    In the plunker you copied it applies a class called .grey when it is true but in conjunction with the css, he has e.g: .grey .overlay, the result is the desired.

    If you want to copy that exact logic you have to add the .grey class and also change your css.

    e.g:

    css:

    .grey .overlay {
        background-color: #e9e9e9;
        /* display: none; */
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        opacity: 0.5;
    }
    

    and html:

    <div ng-controller="mainCtrl" ng-class="{true: 'grey'}[madeCall]">
    

    plunker