Kirill Pakhomov
Kirill Pakhomov

Reputation: 87

Passing data to the modal window. Angular js

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.

Upvotes: 0

Views: 54

Answers (2)

casraf
casraf

Reputation: 21694

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) {
    ...
});

Upvotes: 2

csschapker
csschapker

Reputation: 129

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.

Upvotes: 0

Related Questions