Angular-ui bootstrap modal without creating new controller

前端 未结 3 2024
[愿得一人]
[愿得一人] 2021-02-12 14:06

plunk: http://plnkr.co/edit/85Wl5W If I use the $modalInstance on the same controller(modalController.js), without being in a modal, angular gets frozen.

I just want to

3条回答
  •  无人共我
    2021-02-12 14:14

    It was possible in older version of UI-Bootstrap 0.10.0 .Even latest version,it works for me

    index.html

        
    
    
    
    
    
    
    

    modalDemoController.js

    $scope.openModal=function(){
        $scope.modalInstance=$modal.open({
            templateUrl: 'myTestModal.tmpl.html',
            scope:$scope
        });
    }
    
    $scope.close=function(){
        $scope.modalInstance.dismiss();//$scope.modalInstance.close() also works I think
    };
    
    $scope.doSomething=function(){
        //any actions to take place
        console.log("Do Something");
    }
    

提交回复
热议问题