每次我点击执行$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/