2017-09-04 18 views
0

我使用角度ui作为模式,当我按下它时,它进入我指定的数组,但它不会立即更新它应该,我仍然必须刷新页面AngularJS不会立即更新当我推入Modal

<button class="btn btn-regular mustard-lighten-1 white-text" ng-click="showModal()"><span class="material-icons">add</span></button> 

$scope.showModal =() => { 
    let modalInstance = $uibModal.open({ 
     animated: true, 
     templateUrl: 'pages/modals/add-modal.html', 
     controller: 'homeController' 
    }) 
} // show modal on the overview page 

$scope.addRule =() => { 

    $scope.rules.push({ 
     // properties inside here 
    }) 

回答

0

更新1:试试这个。

$timeout(function() { 
    $scope.rules.push({ 
     // properties inside here 
    }); 
},1100); 

试试这个,这为我工作:

$rootScope.$apply(function() { 
    $scope.rules.push({ 
     // properties inside here 
    }); 
}); 
+0

你的意思是里面插入我的 “addRule” 功能的其他功能? – BlackenedRed

+0

是的。它将更新Scope中的视图。 –

+0

它会引发错误“错误:[$ rootScope:inprog] $ apply already progress in progress” – BlackenedRed