AngularJS NG-Klasse-odd 指令
AngularJS 实例
为表格的奇数行设置::
<! DocType html> <html> <kopf> <meta charset = "utf-8"> <script src = "http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js" Hintergrundfarbe: schwarz;} </style> </head> <body ng-App = "myapp"> <table ng-controller = "myctrl"> <tr ng-repeat = "x In Records" ng-class-odd = "Striped '" <td>{{x.Country}}</td></tr></table><script>var app = angular.module("myApp", []);app.controller("myCtrl", function($scope) { $scope.records = [ { "Name" : "Alfreds Futterkiste", "Country" : "Germany" }, { "Name" : "Berglunds Snabbk", "Land": "Schweden"}, {"Name": "Centro comercial moctezuma", "Land": "Mexiko"}, {"Name": "Ernst Händel", "Land": "Österreich"});运行结果 :
| Alfreds Futterkiste | Deutschland |
| Berglunds Snabbk | Schweden |
| Centro Comercial Moctezuma | Mexiko |
| Ernst Händel | Österreich |
定义和用法
NG-Klasse-odd 指令用于为 html 元素动态的绑定一个或多个 CSS 类 , 但只作用于奇数行。 但只作用于奇数行。
NG-Klasse-odd 指令需要与 ng-repeat 指令搭配使用。
NG-Klasse-odd 指令建议用在表格的样式渲染中 , 但是所有 html 元素都是支持的。
语法
<Element ng-class-odd = "expression"> </element>
所有 html 元素都支持。
参数值
| 值 | 描述 |
|---|---|
| Ausdruck | 表达指定一个或多个 CSS 类。 |
以上就是对 AngularJs 资料的整理 , 有需要的朋友参考下。