0
votes

I am new to AngularJS and am trying to figure out a simple way of displaying a modal dialog (using Angular-UI-Bootstrap) for $http call errors and pass the error text from the calling controller to the $scope used by the dialog's template.

I've created a Plunker to illustrate my issue at: http://plnkr.co/edit/nMdjJ256tH9oA9kRpUtV?p=preview

See line 21 in example.js for what I'm attempting to do.

Thanks in advance, NY

2
what is your question?artur grzesiak
the dialog template has placeholders for {{error.title}} and {{error.text}}. how do I pass these values from the calling controller when opening my modal dialog?nyl66

2 Answers

2
votes

To pass external values to dialog controller you set resolve option appropriately. Then the resolved objects will be available as parameters in the dialog controller.

HERE is the corrected version of your code.

0
votes

You can also pass a custom scope to your modal's controller (at least on ui-bootstrap version 0.8.0). This way, your DialogController does not depend on the resolved object all the time; if you don't pass that object, you will get an injection error.

In the application I'm working on, we call the DialogController from different places and only in some cases, we need to pass some data.

You can see this working here: http://plnkr.co/edit/jn94Zl?p=preview

It all depends on your specific needs.