如何在 angular js 中从控制器调用$modal.open
。以前在ui-bootstrap 0.1.0对话框中有对话框。现在在当前版本中,调用对话的权限是什么。
在 0.1.0 中,它只是 $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 吗?
设置一个函数来做 open:(设置模板、控制器、解析)
function open() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
items: function () {
return $scope.items;
}
}
});
});
设置模态控制器:
var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
$scope.items = items;
});
并在需要时调用它:
open();
如果要从模板调用:
取代
function open() {
自
$scope.open = function() {
并致电
$scope.open()