我试图在模型窗口打开时将某些模型数据传递给模态窗口。当用户点击某个元素时,我希望打开模式窗口并显示与点击内容有关的更多详细信息。Angular-ui模态 - 将数据传入模态
我创建了一个plunker,它工作的方式除了将数据传递到模态窗口之外我想要的。
我试图通过使用数据NG点击:
<img ng-src="{{item.picture}}" width="100" ng-click="open(item)"/>
谁能帮助我?或者指向正确的方向?
我试图在模型窗口打开时将某些模型数据传递给模态窗口。当用户点击某个元素时,我希望打开模式窗口并显示与点击内容有关的更多详细信息。Angular-ui模态 - 将数据传入模态
我创建了一个plunker,它工作的方式除了将数据传递到模态窗口之外我想要的。
我试图通过使用数据NG点击:
<img ng-src="{{item.picture}}" width="100" ng-click="open(item)"/>
谁能帮助我?或者指向正确的方向?
如何this?
我加入了项目的决心
resolve: {
items: function() {
return $scope.items;
},
item: function(){
return size;
}
}
而在controller
我做:注射item
我已经在http://plnkr.co/FzU5SOv3pdZmAPAIOzdo为你制作了一个重磅炸弹。
你想解决你的数据很像你目前的项目。
$scope.open = function (size) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
resolve: {
items: function() {
return $scope.items;
},
size: function() {
console.log('size: ', size);
return size;
}
}
});
,并在你的模态控制器确保包括现在已经得到解决大小对象如下:
angular.module('ui.bootstrap.demo').controller('ModalInstanceCtrl', function ($scope, $modalInstance, items, size) {
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.size = size;
$scope.ok = function() {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
});
什么为我工作后$scope.item = item;
是内resolve
返回一个对象创建一个对象拥有我想分享的变量。
resolve: {
shared: function(){
return {
name: 'Spencer',
numbers: [1, 2, 3]
}
}
}
要访问shared
对象,请在定义模态实例控制器时包含它。
app.controller('ModalInstanceController', function($scope, shared, $uibModalInstance,