【问题标题】:How to open $uibModal from within modal Controller?如何从模态控制器中打开 $uibModal?
【发布时间】:2017-09-17 03:59:00
【问题描述】:

我有这个代码:

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

【问题讨论】:

    标签: angularjs modal-dialog angular-ui-bootstrap


    【解决方案1】:

    您应该能够以与打开第一个模式大致相同的方式打开第二个模式...

    $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
        }
      };  
    });
    

    【讨论】:

    • 我认为代码有错误,可能是由于一些更新:modalInstance.then应该是modalInstance.result.then
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    相关资源
    最近更新 更多