angularjs ng-class-odd指令
Angularjs实例
为表格的奇数行设置:
<!doctype html> <html> <head> <meta charset =“ utf-8”> <script src =“ http://apps.bdimg.com/lib.com/libs/angular.js/angular.js/1.4.6/angular.min.min.min.js”>背景色:黑色;} </style> </head> <hody ng-app =“ myApp”> <table ng-controller =“ myctrl”> <tr ng-repeat =“ records in Records” ng-class-odd =“ ng-class-odd =”' <td> {{X.country}} </td> </td> </tr> </table> <script> var app = angular.module(“ myApp”,[],[]); app.controller(“ myctrl”,function($ scope) :“ Berglunds snabbk”,“ country”:“瑞典”},{“ name”:“ Centro Moctezuma”,“ country”:“ Mexico”},{“ Name”:“ Ernst Handel”,“ country”,“ countion”,“ actaria”:“ Authia”}}]}})运行结果:
| Alfreds Futterkiste | 德国 |
| Berglunds Snabbk | 瑞典 |
| Centro商业Moctezuma | 墨西哥 |
| 恩斯特·汉德尔 | 奥地利 |
定义和用法
ng-class-odd指令用于为html元素动态的绑定一个或多个css类,但只作用于奇数行。,但只作用于奇数行。
ng-class-odd指令需要与ng repeat指令搭配使用。
ng-class-odd指令建议用在表格的样式渲染中,但是所有html元素都是支持的。
语法
<元素ng-class-odd =“ expression”> </element>
所有html元素都支持。
参数值
| 值 | 描述 |
|---|---|
| 表达 | CSS类。 |
以上就是对angularjs资料的整理,有需要的朋友参考下。,有需要的朋友参考下。