AngularJS - AlertFactory open dialog behavior

巧了我就是萌 提交于 2019-12-24 14:23:25

问题


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:


You need an $apply to invoke a digest cycle.

ng.element(document).on('keydown', function(e){
  //alert('keydown');
  //openDialog();
  $rootScope.$broadcast('openDialog');
  $rootScope.$apply();
});


来源:https://stackoverflow.com/questions/15565462/angularjs-alertfactory-open-dialog-behavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!