Angularjs ng-classe-odd 指令
Angularjs 实例
为表格的奇数行设置:
<! Doctype html> <html> <éadf> <meta charset = "utf-8"> <script src = "http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"> </cript> <style>. Background-Color: Black;} </ Style> </ Head> <Body ng-App = "MyApp"> <Table Ng-Controller = "Myctrl"> <tr ng-repeat = "x dans les enregistrements" ng-class-odd = "'Striped'"> <td> {{{x.name}} </td> <Td> {{x.country}} </td> </tr> </pally> <cript> var app = angular.module ("myApp", []); app.Controller ("myctrl", fonction ($ scope) {$ scope.records = [{"name": "Alfreds Futterkiste : "Bergluds snabbk", "country": "Sweden"}, {"name": "Centro Comercial Moctezuma", "Country": "Mexico"}, {"Name": "Ernst Handel", "Country": "Austria"}]}); </script> </ / body> </html>:
| Alfreds Futterkiste | Allemagne |
| Bergluds snabbk | Suède |
| Centro Comercial Moctezuma | Mexique |
| Ernst Handel | Autriche |
定义和用法
ng-classe-odd 指令用于为 html 元素动态的绑定一个或多个 css 类 , 但只作用于奇数行。
ng-classe-odd 指令需要与 ng-repeat 指令搭配使用。
ng-classe-odd 指令建议用在表格的样式渲染中 , 但是所有 html 元素都是支持的。
语法
<élément ng-class-odd = "expression"> </element>
所有 html 元素都支持。
参数值
| 值 | 描述 |
|---|---|
| expression | 表达指定一个或多个 CSS 类。 |
以上就是对 Angularjs 资料的整理 , 有需要的朋友参考下。