zoukankan      html  css  js  c++  java
  • ngClass指令3种使用

    CSS代码:
    1
    .strike { 2 text-decoration: line-through; 3 } 4 .bold { 5 font-weight: bold; 6 } 7 .red { 8 color: red; 9 }

    1.映射语法

    1 <p ng-class="{strike: deleted, bold: important, red: error}">Map Syntax Example</p>   
    2 <input type="checkbox" ng-model="deleted"> deleted (apply "strike" class)<br>  
    3 <input type="checkbox" ng-model="important"> important (apply "bold" class)<br>
    4 <input type="checkbox" ng-model="error"> error (apply "red" class)
    5 <hr>
      //strike, bold, improtant为true时,将分别引用类名deleted, bold, error
     

    2.字符串语法

    <p ng-class="style">Using String Syntax</p>
    <input ng-model="style" type="text" placeholder="bold strike red">
    </hr>
      //类名多个有效,空间隔开即可

    3.数组语法

    <p ng-class="[style1, style2, style3]">Using Array Syntax</p>
    <input ng-model="style1" type="text" placeholder="bold, strike or red"></br>
    <input ng-model="style2" type="text" placeholder="bold, strike or red"></br>
    <input ng-model="style3" type="text" placeholder="bold, strike or red"></br>
    </hr>

    4.ngClassEven与ngClassOdd

    css:

    .odd {
      color: red;
    }
    .even {
      color: blue;
    }
    <ol ng-init="names=['John', 'Mary', 'Cate', 'Suz']">
      <li ng-repeat="name in names">
       <span ng-class-odd="'odd'" ng-class-even="'even'">
         {{name}}      
       </span>
      </li>
    </ol>

  • 相关阅读:
    【Henu ACM Round#17 A】Simple Game
    【Henu ACM Round #12 E】Thief in a Shop
    【Henu ACM Round#16 D】Bear and Two Paths
    【Henu ACM Round#16 A】 Bear and Game
    P4824 [USACO15FEB]Censoring (Silver) 审查(银)
    P4001 [BJOI2006]狼抓兔子
    P2444 [POI2000]病毒
    P3966 [TJOI2013]单词
    P3796 【模板】AC自动机
    P4574 [CQOI2013]二进制A+B
  • 原文地址:https://www.cnblogs.com/lianghaijie-ctw/p/6431488.html
Copyright © 2011-2022 走看看