search

Home  >  Q&A  >  body text

angular.js - angularjs ng-class issue

Why is this all_font_color not taking effect?

allFontColor in scope is indeed true

高洛峰高洛峰2839 days ago557

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-05-15 17:01:50

    Thank you everyone. I still don’t know how to solve yesterday’s problem. I don’t know why.
    Finally I changed the writing method and solved it using class="{{all_font_color_}}"this method

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-15 17:01:50

    You posted the entire code of ng-class. You can’t see it on the right side. I wonder if there is something wrong with your format

    reply
    0
  • PHPz

    PHPz2017-05-15 17:01:50

    1. Determine whether the class exists

    2. Make sure the class style is not overwritten

    You can test it in plnkr

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 17:01:50

    I feel like you should write like this:
    ng-class="{true:'active',false:'inactive'}[tabVal==2]"
    The meaning of the above expression is: by judging whether 'tabVal' is equal to 2, To determine the style value of ng-class;
    If tabVal==2 is true, then ng-class='active';
    where tabVal can be defined in the controller and can be a variable;
    active is any class name;

    reply
    0
  • Cancelreply