当我推入Modal时,AngularJS不会立即更新

时间:2017-09-04 06:52:40

标签: javascript html angularjs

我正在使用角度ui作为模态,当我按下时,它进入我指定的数组但它不会像它应该的那样立即更新,我仍然需要刷新页面

<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
    })

1 个答案:

答案 0 :(得分:0)

更新1:试试这个。

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

试试这个,这对我有用:

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