如何在每次更改时刷新orderBy

时间:2017-04-21 08:06:33

标签: angularjs angularjs-ng-repeat angularjs-orderby

我有一个检查值是true还是false的函数以及一个改变值的函数。

checkValue(item){  
    if item.exists{  
        return 1;  
    }  
    else {  
        return 0;  
    }  
} 

在我的html中,我有一个ng-repeat按此函数命令:

<span ng-repeat="item in items | orderBy: checkValue"></span>
<a ng-click="changeItemExists(selectedItem)">

现在,当item.exists更改orderBy时,item.exsist无效并再次订购。

如何让订单查看import java.util.Scanner; public class week4 { public static void main(String[] args) { { String studentname; int mark = 100; // listing maximum mark Scanner inText = new Scanner(System.in); System.out.print("Please enter the name of the student >> "); studentname = inText.nextLine(); Scanner inNumber = new Scanner(System.in); System.out.print("Please enter mark for student " + studentname + " out of 100 >> "); mark = inText.nextInt(); if(mark <50) System.out.print("The grade for " + studentname + " is F " ); else if(mark <65) System.out.print("The grade for " + studentname + " is P " ); else if(mark <75) System.out.print("The grade for " + studentname + " is C " ); else if(mark <85) System.out.print("The grade for " + studentname + " is D " ); else System.out.print("The grade for " + studentname + " is HD2" ); } } }

中的任何更改

1 个答案:

答案 0 :(得分:0)

您不需要checkValue功能。 只是做:

<span ng-repeat="item in items | orderBy: 'exists'"></span>

然后,orderBy会自动刷新订单,并对“存在”进行任何更改。属性。