1

i'm creating an AlertFactory because ui.bootstrap.dialog doesn't works in my app.

So i type follow code: http://jsfiddle.net/Premier/BHqKB/17/

enter code here

It works very well if you click on the "Open dialog" button: on screen appear a dialog with my messages.

I also register a listener on keydown: listener fires a broadcast event on which is registered a scope related function. This function calls openDialog to show the dialog. In this way angular doesn't interpolates arguments and alert is shown with {{title}} placeholder.

What is wrong in my code?

Thank you.

1 Answer 1

1

You need an $apply to invoke a digest cycle.

ng.element(document).on('keydown', function(e){
  //alert('keydown');
  //openDialog();
  $rootScope.$broadcast('openDialog');
  $rootScope.$apply();
});
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. Problem is that 'MessageBoxController' was not instantiated and title, message and buttos are null after call $apply.
And when are those properties initialized?
I'm sorry, your solution works perfectly. Thank you. Problem was about my distraction about controller name: there was 2 controllers with name MessageBoxController

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.