AngularJS - AlertFactory打开对话框行为 [英] AngularJS - AlertFactory open dialog behavior
问题描述
我创建一个AlertFactory因为ui.bootstrap.dialog没有作品在我的应用程序。
i'm creating an AlertFactory because ui.bootstrap.dialog doesn't works in my app.
所以,我跟随型code: http://jsfiddle.net/premier / BHqKB / 17 /
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.
我也上的keydown注册一个监听器:监听器触发其上注册的范围相关的功能广播事件。此函数调用openDialog来显示该对话框。这样的角度不插参数和警报显示为{{title}}的占位符。
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.
什么是错误的,我code?
What is wrong in my code?
感谢您。
推荐答案
您需要一个 $适用
来调用消化周期。
You need an $apply
to invoke a digest cycle.
ng.element(document).on('keydown', function(e){
//alert('keydown');
//openDialog();
$rootScope.$broadcast('openDialog');
$rootScope.$apply();
});
这篇关于AngularJS - AlertFactory打开对话框行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!