如何在模态打开/激活时为模态内容设置新值?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