In my HTML, I have an element with a ng-click attribute to trigger a function. This function contains a loop which calls another function in each step. Now, I would like to refresh my $scope after every step of the loop, but:
- I can't use
$scope.$applysince I'm already inside an$applyphase due to theng-clickattribute, - I can't use
onclickinstead ofng-clickbecause the click function changes (withng-repeatspecifically), and $timeoutdoesn't work because it somehow messes the order in which the function inside the loop runs (I guess the click function runs the loop and then the bit inside$timeouttakes place).
Here's my code:
// IN MY HTML
<th class="groupHeader" ng-repeat="j in groupsMain" ng-click="thClickColumn(j)">{{j}}</th>
// IN MY CONTROLLER
$scope.thClickColumn = function(j) {
// some code
for ( var i = 1 ; i <= 7 ; i++ ) {
_this.tdClick(i,j) ; // I'd like my $scope to refresh after doing this
if ( _this.inputElement === false ) { retu ; } // Also, this bit here should break the loop if the condition is met (_this.inputElement is retued by the function above)
}
} ;
Thanks!
