如何在模態打開/激活時爲模態內容設置新值?Angularjs Modal - 如何在模態打開時動態設置模態內容
以下是示例代碼。
angular.module('plunker', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal, $log, $timeout) {
$scope.test = "test variable"
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
test: function() {
return $scope.test;
}
}
});
$timeout(function(){
$scope.test = "Hello World!";
}, 5000);
};
var ModalInstanceCtrl = function ($scope, $modalInstance, test) {
$scope.test = test;
$scope.$watch('test',function (newValue, oldValue) {
$scope.test = test;
});
};
在父控制器,我初始化以「測試變量」和超時後(5秒),我想模態變量的變化爲「Hello World」無收模態的模態1日。
可以測試here
謝謝你的男人.. – Sh4m
高興它幫助.... – jitender