繁体   English   中英

如何从angularjs中的控制器调用Ui-Bootstrap 0.10.0中的$ modal.open

[英]How to call $modal.open in Ui-Bootstrap 0.10.0 from controller in angularjs

如何在角度js中从控制器调用$modal.open 以前在ui-bootstrap中有0.1.0对话框。 现在在当前版本中,调用对话框的权限是什么。

在0.1.0中它只是$ dialog.dialog(); 然后调用Dialog(); 在Lib -

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吗?

设置要打开的功能:(设置模板,控制器,解析)

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()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM