我有这段工作代码(如下),它的功能和功能应该很好,但是它不是最佳的,可以请帮助我用 $watch 方法重写它吗?我进行了几次尝试,但没有成功。这是我的线程引用这个: 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();
}