I am trying to pass some model data into a modal window when it is opened. When the user clicks on an element I want to have the modal window open and display more detailed
I've made a plunker for you at http://plnkr.co/FzU5SOv3pdZmAPAIOzdo.
You want to resolve your data much like you do items currently.
$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;
}
}
});
and in your modal controller make sure to include the now resolved size object as follows:
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');
};
});