AngularJS:将变量传递给模态
AngularJS: pass variable to modal
我使用https://github.com/simpulton/angularjs-wizard对于我的项目来说,它是有效的,(我稍微修改了一下,把var app
换成了$scope
)
但我需要将一个变量传递给open
函数:
$scope.open = function (image)
{
$scope.image = image;
var modalInstance = $uibModal.open({
templateUrl: 'wizard.html',
controllerAs: 'modal',
size: 'lg',
controller: 'ModalCtrl',
resolve: {
image: function () {
return image;
}
}
});
modalInstance.result
.then(function (data) {
$scope.closeAlert();
$scope.summary = data;
}, function (reason) {
$scope.reason = reason;
});
};
以及在html:中
ng-click="open(image)"
但在我的模板中image
是undefined
如果我只使用模态窗口,它就会工作https://angular-ui.github.io/bootstrap/#/modal,但没有这个向导示例
更新:
https://jsfiddle.net/Ginstay/znz64sk3/2/
是的,当我打开模式窗口时,ajax就完成了
如果我在return image;
图像中添加断点,是否存在
试试这个
angular.module('plunker', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
test: function () {
return 'test variable';
}
}
});
};
var ModalInstanceCtrl = function ($scope, $modalInstance, test) {
$scope.test = test;
};
我想好了,我需要添加
$scope.image = image;
至ModalCtrl
相关文章:
- 将变量从link_to传递到rails中的模态
- AngularJS:将变量传递给模态
- 使用帮助程序中使用的模态传递轨道变量link_to
- 发送到模态的 JavaScript 变量
- 将变量从脚本传递到模态中
- 将变量从 Javascript 传递到 PHP - 弹出窗口/模态窗口
- 轨道使用模态变量和局部变量呈现部分
- 将变量传递给模态
- 将变量传递到Bootstrap模态中
- 用javascript变量填充jquery模态表单字段值
- 使用jquery将多个items变量传递到Bootstrap模态中
- 如何从控制器监视服务中的变量以打开模态
- 模态上的React-不变量冲突
- 超链接与变量创建一个模态框/弹出
- 在模态中显示Javascript变量
- 如何传递变量到动态UIkit模态
- 使用UIKIT模态获取变量(而不是提示符)
- 如何检查和传递变量,如果保存按钮在模态点击?javascript
- 变量被重置为'1'在模态窗口
- 将jQuery模态变量传递给PHP脚本