如何在 Angular js 中从 Controller 调用 $modal.open
。以前在 ui-bootstrap 0.1.0 对话框中有。现在在当前版本中调用对话框的权限是什么。
在 0.1.0 中它只是 $dialog.dialog();然后调用Dialog();在图书馆 -
return {
// Creates a new `Dialog` with the specified options.
dialog: function(opts){
return new Dialog(opts);
},
// creates a new `Dialog` tied to the default message box template and controller.
//
// Arguments `title` and `message` are rendered in the modal header and body sections respectively.
// The `buttons` array holds an object with the following members for each button to include in the
// modal footer section:
// * `result`: the result to pass to the `close` method of the dialog when the button is clicked
// * `label`: the label of the button
// * `cssClass`: additional css class(es) to apply to the button for styling
messageBox: function(title, message, buttons){
return new Dialog({templateUrl: 'template/dialog/message.html',
controller: 'MessageBoxController', resolve: {model: {
title: title,
message: message,
buttons: buttons
}}});
}
有谁知道如何在 0.10.0 中调用 $modal.open 吗?
最佳答案
设置函数打开:(设置模板、 Controller 、解析)
function open() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
items: function () {
return $scope.items;
}
}
});
});
设置模态 Controller :
var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
$scope.items = items;
});
并在需要时调用它:
open();
如果你想从模板调用:
替换
function open() {
到
$scope.open = function() {
并调用
$scope.open()
关于javascript - 如何从 angularjs 中的 Controller 调用 Ui-Bootstrap 0.10.0 中的 $modal.open,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21751729/