Search code examples
angularjsbindonce

AngularJs - Bindonce force refresh using refreshOn attribute


I am trying to force refresh my bindonce table after editing few records but I dont know how to use bindonce refreshOn attribute.

HTML Code:

<tbody bindonce="filteredItems" refresh-on="refreshTaskList" ng-repeat="task in filteredItems | orderBy:sortingOrder:reverse">
<tr>
 <td><span bo-bind="task.serviceTypeName | isEmpty : 'None'"></span></td>
  <td ><span bo-bind="task.percentageCompleted | isEmpty : 'Not Started'"></span></td>
</tr>
</tbody>

I am calling this line in my Controller:

$scope.refreshTaskList();

Also, I tried calling this as well but nothing works:

$scope.$broadcast('refreshTaskList');

Can you anyone please help me how to use this in a proper manner?


Solution

  • Change it to: refresh-on="'refreshTaskList'"

    Example:

    <button ng-click="refresh()">Refresh table</button>
    
    $scope.refresh = function () {
      $scope.$broadcast('refreshTaskList');
    };
    

    If it still doesn't work you might have a version that doesn't contain the refresh-on attribute.

    Demo: http://plnkr.co/edit/nYPDMRG4b1OtkMolEEDQ?p=preview