使用JavaScript在AngularJS引导界面调用模式窗口 [英] Invoking modal window in AngularJS Bootstrap UI using JavaScript
问题描述
使用本例中提到这里,我怎么能调用模式窗口使用JavaScript,而不是点击一个按钮?
Using the example mentioned here, how can I invoke the modal window using JavaScript instead of clicking a button?
我是新来AngularJS并试图这里搜索文档和的here 没有运气。
I am new to AngularJS and tried searching the documentation here and here without luck.
感谢
推荐答案
确定,所以首先在 HTTP://角-ui.github.io/bootstrap/ 有一个<&模式GT;
指令和 $对话
服务两者的那些可以用来打开模式窗口。
OK, so first of all the http://angular-ui.github.io/bootstrap/ has a <modal>
directive and the $dialog
service and both of those can be used to open modal windows.
不同的是,使用&LT;&模式GT;
A模式的指令内容嵌入在一个托管模板(一个触发模式窗口打开)。在 $对话
服务更为灵活,并允许您从AngularJS code任何地方加载从一个单独的文件模式的内容,以及触发模式窗口(这是控制器,服务或其他指令)。
The difference is that with the <modal>
directive content of a modal is embedded in a hosting template (one that triggers modal window opening). The $dialog
service is far more flexible and allow you to load modal's content from a separate file as well as trigger modal windows from any place in AngularJS code (this being a controller, a service or another directive).
不知道你所说的使用JavaScript code,但假设你的意思是在AngularJS $ C $任何地方c中的 $对话
服务大概的意思究竟是什么很长的路要走。
Not sure what you mean exactly by "using JavaScript code" but assuming that you mean any place in AngularJS code the $dialog
service is probably a way to go.
这是非常容易使用,并在其最简单的形式,你可以这样写:
It is very easy to use and in its simplest form you could just write:
$dialog.dialog({}).open('modalContent.html');
要说明它可以通过任何JavaScript code在这里真的是触发触发模式带有计时器的版本,在3秒后控制器被实例化:
To illustrate that it can be really triggered by any JavaScript code here is a version that triggers modal with a timer, 3 seconds after a controller was instantiated:
function DialogDemoCtrl($scope, $timeout, $dialog){
$timeout(function(){
$dialog.dialog({}).open('modalContent.html');
}, 3000);
}
这可以看出在本普拉克动作:<一href=\"http://plnkr.co/edit/u9HHaRlHnko492WDtmRU?p=$p$pview\">http://plnkr.co/edit/u9HHaRlHnko492WDtmRU?p=$p$pview
This can be seen in action in this plunk: http://plnkr.co/edit/u9HHaRlHnko492WDtmRU?p=preview
最后,这里是完整的参考文档,这里所描述服务 $对话框:
<一href=\"https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md\">https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md
Finally, here is the full reference documentation to the $dialog
service described here:
https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md
这篇关于使用JavaScript在AngularJS引导界面调用模式窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!