AngularJs ng-class 使用

今天在做项目的时候要对表格内的部分的最大最小值高亮

解决方案

1. 引用 ng-class

2. 引用原型求最大最小值

实例

AngularJs HTML 代码

 1 <table class="ui table celled">
 2     <thead>
 3         <tr>
 4             <th>标题1</th>
 5             <th>标题2</th>
 6             <th>标题3</th>
 7             <th>标题4</th>
 8         </tr>
 9     </thead>
10     <tbody>
11         <tr ng-repeat="(index, item) in items">
12             <td>{{item.list1}}</td>
13             <td>{{item.list2}}</td>
14             <td ng-class="{max:index==1||index==2||index==3}">{{item.list3}}</td>
15             <td ng-class="{max:index==1||index==2||index==3}">{{item.list4}}</td>
16         </tr>
17     </tbody>
18 </table>
View Code

Javascript 代码

1 //求数组的最大,最小值方法
2 Array.prototype.max = function(){
3     return Math.max.apply({},this)
4 };
5 Array.prototype.min = function(){
6     return Math.min.apply({},this)
7 };
View Code

 

posted @ 2014-12-24 15:57  追梦的超哥  阅读(291)  评论(0编辑  收藏  举报