0

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.

2 Answers2

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