خرید بک لینک

Vote count: 1

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.$apply since I'm already inside an $apply phase due to the ng-clickattribute,
  • I can't use onclick instead of ng-click because the click function changes (with ng-repeat specifically), and
  • $timeout doesn'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 $timeout takes 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!

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 7 ارديبهشت 1395 ساعت: 3:28

صفحه بندی