我有這樣的工作代碼(下面),它的功能和做它應該很好,但它不是最佳的,可以請幫助我用$ watch方法重寫它?我曾多次嘗試,但它沒有work.here是我的線指的這一個: angularjs angular doesn't read the length of an array
function dialogWindows($scope) {
$scope.alpeic = [];
$scope.compute=function()
{
$scope.alpeic.push(1);
$scope.records = [
{id:0,
link:$scope.alpeic.length > 5 ? "alpeic.html" : "",
className:$scope.alpeic.length > 5 ? "special" : "normal",
item:"This is item A"},
{id:1,
link:$scope.alpeic.length > 5 ? "alpeic.html" : "",
className:$scope.alpeic.length > 5 ? "special" : "normal",
item:"This is item B"}];
}
$scope.compute();
}
有趣的可以使用2種不同的方法來評估'NG-class' JS表達......我從來沒有見過你用過的語法...很酷 – charlietfl