Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
 
what is your question? –  artur grzesiak Nov 21 '13 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? –  nyl66 Nov 21 '13 at 21:25
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.