I have this piece of working code (below)which functions and does what it should nicely however it is not optimal, could please help me with rewriting it with the $watch method ? I had several attempts but it didnt work.here is my thread refering to this one: 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();
}
 
     
     
    