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.
我在AngularUI中找不到$ dialog服务,我试图探索一个简单的messageBox()来使用$ modal创建一个确认对话框。也找不到。
Can somebody suggest me how to create a simple dialog (say for delete confirmation) using AngularJS / AngularUI?
有人可以建议我如何使用AngularJS / AngularUI创建一个简单的对话框(比如删除确认)?
Thank you in advance.
先谢谢你。
1 个解决方案
#1
20
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.
对话框服务被重构为$ mod,用于版本0.6.0的ui-bootstrap。来自$ dialog的功能仍然可用,只需通过$ 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.
根据文档,您应该确保在页面中包含bootstrap的css和angular.js以及bootstrap-ui的JS,您可以从doc站点下载它。如果你只需要使用$ modal服务而不是其他指令,我会看看'创建你自己'的链接。
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.
如果这些文件包含在您的页面中,请确保您的角度模块的定义包含ui.bootstrap作为依赖项。例如
var app = angular.module('myApp', ['ui.bootstrap']);
If this is done then you should be able to inject the $modal
service within your module, like you would with any other service.
如果这样做,那么您应该能够在模块中注入$ modal服务,就像使用任何其他服务一样。
app.controller('myController', function($scope, $modal) {
$scope.openModal = function() {
// Can use $modal service as per examples in doc page
};
});
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.
至于可靠的例子,文档页面在页面和plunker(因此你可以使用它们)中为每个服务和指令提供了很好的例子。我想在这里链接到plunker,但我似乎无法。
#1
20
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.
对话框服务被重构为$ mod,用于版本0.6.0的ui-bootstrap。来自$ dialog的功能仍然可用,只需通过$ 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.
根据文档,您应该确保在页面中包含bootstrap的css和angular.js以及bootstrap-ui的JS,您可以从doc站点下载它。如果你只需要使用$ modal服务而不是其他指令,我会看看'创建你自己'的链接。
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.
如果这些文件包含在您的页面中,请确保您的角度模块的定义包含ui.bootstrap作为依赖项。例如
var app = angular.module('myApp', ['ui.bootstrap']);
If this is done then you should be able to inject the $modal
service within your module, like you would with any other service.
如果这样做,那么您应该能够在模块中注入$ modal服务,就像使用任何其他服务一样。
app.controller('myController', function($scope, $modal) {
$scope.openModal = function() {
// Can use $modal service as per examples in doc page
};
});
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.
至于可靠的例子,文档页面在页面和plunker(因此你可以使用它们)中为每个服务和指令提供了很好的例子。我想在这里链接到plunker,但我似乎无法。