关闭弹出容器时如何重新加载页面?

时间:2018-03-22 11:24:18

标签: angularjs angularjs-material

我使用$ mdDialog显示弹出警报。每当我关闭弹出容器时,我想刷新页面。

 $scope.updateCustomer = function(){
   HomeService.updateCustomer($scope.update)
    .then (function success(response){ 
        $mdDialog.show(
            $mdDialog.alert()
              .parent(angular.element(document.querySelector('#popupContainer')))
              .clickOutsideToClose(true)
              .textContent("Username has been changed successfully!")
              .ariaLabel('')
              .ok('Ok')
          );
    },
    function error(response){
        $mdDialog.show(
            $mdDialog.alert()
              .parent(angular.element(document.querySelector('#popupContainer')))
              .clickOutsideToClose(true)
              .textContent("Something is wrong!")
              .ariaLabel('')
              .ok('Ok')
          );
  });
} 

关闭弹出式容器时如何刷新页面?

2 个答案:

答案 0 :(得分:1)

这是我的问题的工作答案......

 $scope.updateCustomer = function(){
   HomeService.updateCustomer($scope.update)
    .then (function success(response){ 
        $mdDialog.show(
            $mdDialog.alert()
              .parent(angular.element(document.querySelector('#popupContainer')))
              .clickOutsideToClose(true)
              .textContent("Username has been changed successfully!")
              .ariaLabel('')
              .ok('Ok')
              .onRemoving(window.location.reload())
          );

    },
    function error(response){
        $mdDialog.show(
            $mdDialog.alert()
              .parent(angular.element(document.querySelector('#popupContainer')))
              .clickOutsideToClose(true)
              .textContent("Something is wrong!")
              .ariaLabel('')
              .ok('Ok')

          );              
  });
} 

答案 1 :(得分:0)

页面重新加载并不是angularjs模式,但您可以使用:

$mdDialog
  .show({
    ...
    onRemoving: function() {
      window.location.reload();
    }
  });

参考:$mdDialog Service