如何从控制器刷新单击按钮上的自定义指令

时间:2018-10-25 06:38:02

标签: angularjs

我有以下简单的指令定义

 <div>
  <location-file-upload></location-file-upload>
  <button ng-click="refresh()">Reload</button>
</div>

在Controller中,我们如何刷新以上指令?

$scope.refresh = function(){
//code here
}

1 个答案:

答案 0 :(得分:1)

<div ng-if="reRender">
    <location-file-upload></location-file-upload>
    <button ng-click="refresh()">Reload</button>
</div>

$scope.refresh = function(){
    $scope.reRender = false;
    $timeout(function() {
        $scope.reRender = true;
    )};
}