Angularjs ng-class-odd 指令
angularjs 实例
为表格的奇数行设置 :
<! doctype html> <html> <head> <meta charset = "utf-8"> <script src = "http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"> </script> <style> .Striped {white : white; 배경색 : black;} </style> </head> <body ng-app = "myapp"> <table ng-controller = "myctrl"> <tr ng-repeat = "x in Records"ng-class-odd = " 'Striped'"> <td> {{x.name}} </td> <td> {{x.country}} </td> </tr> </table> <cript> var app = angular.module ( "myApp"), []); app.controller ( "myctrl", function ($ scope) {$ scope.records = [{ "name": "intergreds", "", "in germany" "이름": "Berglunds Snabbk", "Country": "Sweden"}, { "name": "Centro Comercial Moctezuma", "Country": "Mexico"}, "이름": "Ernst Handel", "Country": "Austria"}]}); </html> </html>运行结果 :
| Alfreds Futterkiste | 독일 |
| Berglunds snabbk | 스웨덴 |
| Centro Comercial Moctezuma | 멕시코 |
| Ernst Handel | 오스트리아 |
定义和用法
ng-class-odd 指令用于为 html 元素动态的绑定一个或多个 css 类, 但只作用于奇数行。
ng-class-odd 指令需要与 ng-repeat 指令搭配使用。
ng-class-dodd 指令建议用在表格的样式渲染中 指令建议用在表格的样式渲染中, 但是所有 html 元素都是支持的。
语法
<요소 ng-class-odd = "expression"> </element>
html t
参数值
| 值 | 描述 |
|---|---|
| 표현 | CSS s |
以上就是对 angularjs ular, 有需要的朋友参考下。