So I've got a json file from which I outputed the list of contacts in the table. Each row has a button to click on to proceed to the modal window with that particular row you've clicked on. I handled the window but I can't figure out how do I pass that data to the modal window.
Asked
Active
Viewed 47 times
0
-
Is your modal built using a directive? – Shaggy13spe Aug 16 '16 at 14:20
-
I recommend this: http://stackoverflow.com/questions/20181323/passing-data-between-controllers-in-angular-js?rq=1 – Max Sorin Aug 16 '16 at 14:24
2 Answers
2
If you're using bootstrap UI, you can add it as a resolve
entry:
yourItems = [...];
$uibModal.open({
...
controller: 'MyModalCtrl as modal',
resolve: {
modalItems: function() {
return yourItems;
}
}
})
And inject it into your controller like so:
angular.module('myApp').controller('MyModalCtrl', function(yourItems) {
...
});

casraf
- 21,085
- 9
- 56
- 91
0
I'm not exactly sure how you're project is set up, but there are two libraries that I recommend for creating modals easily.
ngDialog and ui-bootstrap
Both of these have simple methods for attaching data and controllers to dialogs as well as creating your own templates and styles for them.

csschapker
- 129
- 7