0

我正在尝试使用 UI Bootstrap 模态,而不是常规的 Bootsrap 模态。我在父控制器中有一个 $scope.DoIt = function() ,但是当我尝试从模态调用它时,什么也没有发生。

我究竟做错了什么?

如何访问父控制器中的功能?

这是我打开模式的方式:

    applyConfirm: function() {

  if(self.showingExpenses !== true) {

    self.showingExpenses = true;
    var modalInstance = $modal.open({
      animation: true,
      templateUrl: 'applyConfirm.html',
      controller: function($scope, $modalInstance, expenses, jobsService, job) { //'ModalInstanceCtrl',

        angular.extend($scope, {
          expenses: expenses,
          job: job
        });

        $scope.close = function() {
          //self.showingExpenses = false;
          $modalInstance.close();
        };
      }
}
4

1 回答 1

0

scope您可以使用传入的配置设置模式的父范围$uibModal.open,例如

$uibModal.open({
    scope: $scope
    // other properties, etc
})

然后角度范围继承应该使该Dolt方法可用

controller: function($scope, $uibModalInstance /*, etc */) {
    $scope.Dolt(); // this will call the parent scope method
于 2016-09-05T05:56:22.453 回答