javascript - AngularJs $mddialog 如何在每次单击时重新加载 templateurl 中的内容?

标签 javascript angularjs

每次我点击执行$scope.showAdvanced 的按钮时,mddialog 的内容保持不变,即使我更改了post.html 的内容。我什至尝试清除缓存 (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);
        };
      }

    });

最佳答案

AngularJS 有自己的$templateCache。 尝试清除它。

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

关于javascript - AngularJs $mddialog 如何在每次单击时重新加载 templateurl 中的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40077622/

相关文章:

angularjs - 如何告诉 gulp-connect 打开 index.html 而不管 URL?

javascript - React 用不同的组件更新相同的状态

javascript - "cycle"在 CSS 和 onmouseover、onmouseout 类上的 Rails 问题

javascript - DOM 操作在 AngularJS 中添加元素

css - AngularJS - 如何重构 CSS 代码样式

AngularJS If else 语句和/或 switch

html - 如何动态设置 ng-model 以对应对象属性

javascript - page.evaluate 返回空值但浏览器控制台返回正确值

javascript - 为什么我不能在浏览器中构造 `WebAssembly.Memory`?

javascript - 如何使用 _ 和 | 从 javascript 制作数字形状?