AngularJS基礎(chǔ) ng-class-odd 指令示例
AngularJS ng-class-odd 指令
AngularJS 實(shí)例
為表格的奇數(shù)行設(shè)置 class="striped":
<!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> .striped { color:white; background-color:black; } </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> </table> <script> var app = angular.module("myApp", []); app.controller("myCtrl", function($scope) { $scope.records = [ { "Name" : "Alfreds Futterkiste", "Country" : "Germany" }, { "Name" : "Berglunds snabbk", "Country" : "Sweden" }, { "Name" : "Centro comercial Moctezuma", "Country" : "Mexico" }, { "Name" : "Ernst Handel", "Country" : "Austria" } ] }); </script> </body> </html>
運(yùn)行結(jié)果:
Alfreds Futterkiste | Germany |
Berglunds snabbk | Sweden |
Centro comercial Moctezuma | Mexico |
Ernst Handel | Austria |
定義和用法
ng-class-odd 指令用于為 HTML 元素動(dòng)態(tài)的綁定一個(gè)或多個(gè) CSS 類,但只作用于奇數(shù)行。
ng-class-odd 指令需要與 ng-repeat 指令搭配使用。
ng-class-odd 指令建議用在表格的樣式渲染中,但是所有HTML元素都是支持的。
語法
<element ng-class-odd="expression"></element>
所有 HTML 元素都支持。
參數(shù)值
值 | 描述 |
---|---|
expression | 表達(dá)指定一個(gè)或多個(gè) CSS 類。 |
以上就是對(duì)AngularJS資料的整理,有需要的朋友參考下。
相關(guān)文章
詳解AngularJS中module模塊的導(dǎo)入導(dǎo)出
本文給大家介紹angularjs中module模塊的導(dǎo)入導(dǎo)出,涉及到angularjs module相關(guān)知識(shí),對(duì)angularjs module感興趣的朋友一起看看吧2015-12-12Angular自定義組件實(shí)現(xiàn)數(shù)據(jù)雙向數(shù)據(jù)綁定的實(shí)例
下面小編就為大家分享一篇Angular自定義組件實(shí)現(xiàn)數(shù)據(jù)雙向數(shù)據(jù)綁定的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2017-12-12AngularJS實(shí)現(xiàn)頁面定時(shí)刷新
本篇文章主要介紹了AngularJS實(shí)現(xiàn)頁面定時(shí)刷新,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-03-03Angularjs的ng-repeat中去除重復(fù)數(shù)據(jù)的方法
這篇文章主要介紹了Angularjs的ng-repeat中去除重復(fù)數(shù)據(jù)的方法,涉及AngularJS針對(duì)重復(fù)數(shù)據(jù)的遍歷與過濾技巧,需要的朋友可以參考下2016-08-08AngularJS實(shí)現(xiàn)頁面跳轉(zhuǎn)后自動(dòng)彈出對(duì)話框?qū)嵗a
這篇文章主要介紹了AngularJS實(shí)現(xiàn)頁面跳轉(zhuǎn)后自動(dòng)彈出對(duì)話框?qū)嵗a,然后在文章下面給大家介紹了angularjs頁面加載后自動(dòng)彈窗的實(shí)例代碼,感興趣的朋友參考下吧2017-08-08Angular應(yīng)用里異步打開對(duì)話框技術(shù)詳解
這篇文章主要為大家介紹了Angular應(yīng)用里異步打開對(duì)話框技術(shù)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12Angular2表單自定義驗(yàn)證器的實(shí)現(xiàn)
本文給大家介紹angular2表單自定義驗(yàn)證器的實(shí)現(xiàn),本文給大家介紹的非常詳細(xì),具有參考借鑒價(jià)值,感興趣的朋友一起看看吧2016-10-10