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>. latar belakang-kolor: hitam;} </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> </able> <script> var app = angular.module ("myapp", []); app.controller ("myctrl", function ($ scope) {$ scope.records = [{"name", "alfred" {"alfred": "name" "{" name ":" name "" {"name" {{{{{{{{"name" : "Berglunds snabbk", "country": "swedia"}, {"name": "centro komersial moctezuma", "country": "mexico"}, {"name": "ernst handel", "country": "austria"}]}); </skrip> </body> htm运行结果 :
| Alfreds Futterkiste | Jerman |
| Berglunds Snabbk | Swedia |
| Centro Comercial Moctezuma | Meksiko |
| Ernst Handel | Austria |
定义和用法
ng-class-odd 指令用于为 html 元素动态的绑定一个或多个 css 类 , 但只作用于奇数行。
NG-Class-ODD 指令需要与 NG-REPEAT 指令搭配使用。
NG-Class-ODD 指令建议用在表格的样式渲染中 , 但是所有 html 元素都是支持的。
语法
<elemen ng-class-odd = "ekspresi"> </sement>
所有 html 元素都支持。
参数值
| 值 | 描述 |
|---|---|
| ekspresi | 表达指定一个或多个 CSS 类。 |
以上就是对 AngularJS , , 有需要的朋友参考下。