angular bootstrap ui 情态

angular bootstrap ui modals

我在这里问了一个问题: Angular Boostrap Modal Service 它提供了代码示例,我需要从另一个控制器打开一个模式。我已经设法获得模态显示,但我正在努力连接确定、取消按钮。我的代码仍然与这个问题中的代码相同。我需要从不同的控制器创建模式,但我不知道应该如何设置它,我真的很感激这方面的帮助,我对 Angular.

还是个新手

在 StaffController 中加载模式的示例

$scope.editmodal = function EditModal() {
  var modalInstance = $uibModal.open({
    templateUrl: 'myModalContent.html',
    scope: $scope, //passed current scope to the modal
    size: 'sm',
    closeButtonText: 'Close',
    actionButtonText: 'OK'
  });
};

模态的代码在一个名为:ModalController 的控制器中(这包含此处的示例:https://angular-ui.github.io/bootstrap/

谢谢,

您在模态声明中缺少对控制器的引用,在您的模板中您可以省略 $ctrl 前言,或者您可以提供 controllerAs 属性 指定控制器的名称。 所以你的代码应该是这样的。

HTML:

<button class="btn btn-primary" type="button" ng-click="ok()">OK</button> 
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>

JS:

$scope.editmodal = function EditModal() { 
  var modalInstance = $uibModal.open({ 
    templateUrl: 'myModalContent.html', 
    controller: 'ApiStaffController', 
    size: 'sm' 
  }) 
};