如何从模态控制器中打开 $uibModal?

How to open $uibModal from within modal Controller?

我有这个代码:

app.controller('addEmployeeCtrl', function($scope, $uibModalInstance, newEmployee){
  $scope.addNewVehicle=function(){
    // I want to open a new modal here
  };    
});

您应该能够像打开第一个模式一样打开第二个模式...

$uibModal 服务注入 addEmployeeCtrl 并调用 $uibModal.open() 传入另一个模态配置对象。

app.controller('addEmployeeCtrl', function($scope, $uibModalInstance, $uibModal, newEmployee){

  $scope.addNewVehicle = function(){

    var modalInstance = $uibModal.open({
      templateUrl: 'addVehicle.html',
      controller: 'addVehicleCtrl',
      controllerAs: 'vehicleVm'
      // Any other modal config properties here
    }

    modalInstance.result.then(closedCallback, dismissedCallback);

    function closedCallback(){
      // Do something when the modal is closed
    }

    function dismissedCallback(){
      // Do something when the modal is dismissed
    }
  };  
});