Angular-ui bootstrap modal without creating new controller

前端 未结 3 1963
[愿得一人]
[愿得一人] 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:16

    Just write a function instead of creating new file:

     $scope.yourModal= function (data) {
       var modalInstance = $modal.open({
         template: '
    Do you really want to hurt me?
    ', controller: function($scope, scope){ $scope = scope; }, resolve: { scope: function () { return $scope; } }, size: 'sm' }); } $scope.hurt = function(data){ console.log(data); }

提交回复
热议问题