AngularJs $ mddialog每次点击它时如何重新加载templateurl中的内容?

时间:2016-10-17 02:21:02

标签: javascript angularjs

每次单击执行$ scope.showAdvanced的按钮时,即使我更改了post.html的内容,mddialog的内容也保持不变。我甚至尝试清除缓存(shift + f5),但内容仍然是旧的。

var CardAng=angular.module('CardAng',['ngMaterial','ngMessages']);


    CardAng.controller('AppCtrl', function($scope,$mdDialog){

        $scope.imagePath="img/IMG1.jpg";


        $scope.showAdvanced = function(ev) {
            $mdDialog.show({
              controller: DialogController,
              templateUrl: '/post.html',
              parent: angular.element(document.body),
              targetEvent: ev,
              clickOutsideToClose:true,
              fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
            })
            .then(function(answer) {
              $scope.status = 'You said the information was "' + answer + '".';
            }, function() {
              $scope.status = 'You cancelled the dialog.';
            });
          };

     function DialogController($scope, $mdDialog) {

        $scope.hide = function() {
          $mdDialog.hide();
        };

        $scope.cancel = function() {
          $mdDialog.cancel();
        };

        $scope.answer = function(answer) {
          $mdDialog.hide(answer);
        };
      }

    });

1 个答案:

答案 0 :(得分:3)

angular拥有自己的$ templateCache。试着清除它。

$templateCache.remove('/post.html')$templaceCache.removeAll();