Using ui-router with Bootstrap-ui modal

后端 未结 4 1419
暗喜
暗喜 2020-11-28 21:22

I know this has been covered many times and most articles refer to this bit of code: Modal window with custom URL in AngularJS

But I just don\'t get it. I don\'t fin

4条回答
  •  时光取名叫无心
    2020-11-28 21:57

    The $modal itself doesn't have a close() funcftion , I mean If you console.log($modal) , You can see that there is just an open() function.

    Closing the modal relies on $modalInstance object , that you can use in your modalController.

    So This : $modal.close(result) is not actually a function!

    Notice : console.log($modal); ==>> result :

              Object { open: a.$get

    There is some way to solve this , one way is :

    First you must define a controller in your modal like this :

       $modal.open({
          templateUrl: 'components/new-item/new-item.html',
          controller:"MyModalController"
        });
    

    And then , Later on , :

        app.controller('MyModalController',function($scope,$modalInstance){
          $scope.closeMyModal = function(){
           $modalInstance.close(result);
            }
           // Notice that, This $scope is a seperate scope from your NavbarCtrl,
           // If you want to have that scope here you must resolve it
    
       });
    

提交回复
热议问题