Angular UI 中的 $dialog.messageBox() 在哪里? [英] Where is $dialog.messageBox() in Angular UI?

查看:23
本文介绍了Angular UI 中的 $dialog.messageBox() 在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AngularUI 中找不到 $dialog 服务,我尝试探索一个简单的 messageBox() 来使用 $modal 创建一个确认对话框代码>.也找不到.

I could not find $dialog service in AngularUI and I tried to explore a simple messageBox() to create a confirmation dialog box using $modal. Could not find that either.

有人可以建议我如何使用 AngularJS/AngularUI 创建一个简单的对话框(比如删除确认)?

Can somebody suggest me how to create a simple dialog (say for delete confirmation) using AngularJS / AngularUI?

提前致谢.

推荐答案

$dialog 服务被重构为 $modal 版本 0.6.0 的 ui-bootstrap.$dialog 的功能应该仍然可用,只是通过 $modal 代替.

The $dialog service was refactored into $modal for version 0.6.0 of ui-bootstrap. The functionality from $dialog should still be available, just through $modal instead.

根据docs,你应该确保你已经包含了bootstrap的cssangular.js 以及 bootstrap-ui 的 JS,您可以从文档站点下载.如果您只需要使用 $modal 服务而不是其他指令,我会查看创建您自己的"链接.

According to the docs, you should make sure you have included bootstrap's css and angular.js in your page as well as bootstrap-ui's JS, which you can download from the doc site. I'd look at the 'create your own' link if you only need to use the $modal service and not the other directives.

如果这些文件包含在您的页面中,请确保您的 angular 模块的定义包含 ui.bootstrap 作为依赖项.例如

If these files are included in your page, then make sure the definition of your angular module includes ui.bootstrap as a dependency. e.g.

var app = angular.module('myApp', ['ui.bootstrap']);

如果这样做,那么您应该能够在您的模块中注入 $modal 服务,就像使用任何其他服务一样.

If this is done then you should be able to inject the $modal service within your module, like you would with any other service.

app.controller('myController', function($scope, $modal) {
    $scope.openModal = function() {
       // Can use $modal service as per examples in doc page
    };
});

至于可靠的示例,文档页面在页面上和 plunker 中(因此您可以使用它们)为每个服务和指令提供了很好的示例.我想链接到这里的 plunker,但我似乎无法链接.

As for solid examples, the docs page has great examples on the page and in plunker (so you can play with them) for each of their services and directives. I would like to link to the plunker here, but I don't seem able to.

这篇关于Angular UI 中的 $dialog.messageBox() 在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆