0

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? Commented Nov 21, 2013 at 21:04
  • 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? Commented Nov 21, 2013 at 21:25

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.