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>. خلفية اللون: أسود ؛} </style> </head> <body ng-app = "myapp"> <table ng-controller = "myctrl"> <r ng-repeat = "x in re records" ng-class-odd = "'striped'"> <td> {{x.name}} </td> <td> {{x.country}} </td> </tr> </table> <script> var app = Angular.Module ("myapp" ، []) ؛ app.controller ("myctrl" ، function ($ scope) {$ scope.records = [{"name": "الاسم": "Berglunds snabbk" ، "Country": "Sweden"} ، {"name": "Centro Comercial moctezuma" ، "Country": "Mexico"} ، {"name": "Ernst Handel" ، "Country":: :
| ألفريدز فوتتركيست | ألمانيا |
| Berglunds snabbk | السويد |
| Centro comercial moctezuma | المكسيك |
| إرنست هاندل | النمسا |
定义和用法
ng-class-odd 指令用于为 html 元素动态的绑定一个或多个 css 类 , 但只作用于奇数行。
ng-class-odd 指令需要与 ng-repeat 指令搭配使用。
ng-class-odd 指令建议用在表格的样式渲染中 , 但是所有 html 元素都是支持的。
语法
<element ng-class-odd = "expression"> </element>
所有 HTML 元素都支持。
参数值
| 值 | 描述 |
|---|---|
| تعبير | 表达指定一个或多个 CSS 类。 |
以上就是对 AngularJS 资料的整理 , 有需要的朋友参考下。