2017-09-04 21 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