0

我有一个DIV内的按钮。我正在使用ng-click打开两个模式。一个模式打开时点击DIV和其他按钮。虽然点击DIV模态打开罚款,但是当我点击按钮两个模式都打开。我为模态使用了不同的控制器。我有一个DIV内的按钮。我正在使用ng-click打开两个模式。一个模式打开时点击DIV和其他按钮

HTML

<div class="col-sm-12 row_padding_empty_both mt-10 clear" ng-if="quote.doc.status == 'Quoted'" style="cursor: pointer;" ng-repeat="quote in dbpro | filter: withInSearchOpp " ng-click="openOpp('lg',quote,'quote')"> 
      <div class="media"> 
       <div class="fleft icon-ef-2a" data-options="splash-1 splash-ef-1"> 
         <div class="pull-left thumb " > 
          <img class="media-object img-circle" src="app/images/sample_logo.png" alt=""> 
         </div> 
         {{quote.doc.parent_company.name}}</p> 
          <small class="text-lightred" >{{quote.doc.opp_name}}</small> 
          <small class="text-lightred" style="display:block">{{quote.doc.budgeted_revenue}}</small> 
         </div> 
        <div class="pull-right icons_group "> 

         <button type="button" class="btn btn-rounded-20 btn-default btn-sm" ng-click="openoppMail()" style="width:27px;"><i class="fa fa-paper-plane" ></i></button> 

        </div> 
       </div> 

      </div> 
     </div> 

莫代尔-1 DIV NG-点击功能。

$scope.openOpp = function (size,index,val) { 
     console.log("large modal"); 
     var openOppModel = $modal.open({ 
      templateUrl: 'app/views/modals/oppModal.html', 
      controller: 'oppModalInstanceCtrl', 
      size:size, 
      resolve: { 
       name: function() { 
        return index; 
       }, 
       name1: function() { 
        return val; 
       } 
      } 
     }); 

     openOppModel.result.then(function (selectedItem) { 
      console.log('saved'); 
     }, function() { 
      $log.info('Modal dismissed at: ' + new Date()); 
     }); 
    }; 

莫代尔-2 按钮NG-点击功能

$scope.openoppMail = function (size) { 

     var modalInstance = $modal.open({ 
      templateUrl: 'app/views/modals/mail.html', 
      controller: 'MailComposeCtrl', 
      size: size, 
      resolve: { 
       items: function() { 
        return $scope.items; 
       } 
      } 
     }); 

     modalInstance.result.then(function (selectedItem) { 

     }, function() { 
      $log.info('Modal dismissed at: ' + new Date()); 
     }); 
    }; 
+2

您需要在单击按钮时防止事件的传播。将$ event传递给该函数,并在按钮的点击处理程序中添加$ event.stopPropagation()。 –

+0

@K K,谢谢你。你拯救了我的一天。 – RAMESHKUMAR

回答

0

添加$event.stopPropagation()到该按钮的处理程序。

$scope.openoppMail = function ($event,size) { 
$event.stopPropagation(); 
     var modalInstance = $modal.open({ 
      templateUrl: 'app/views/modals/mail.html', 
      controller: 'MailComposeCtrl', 
      size: size, 
      resolve: { 
       items: function() { 
        return $scope.items; 
       } 
      } 
     }); 

     modalInstance.result.then(function (selectedItem) { 

     }, function() { 
      $log.info('Modal dismissed at: ' + new Date()); 
     }); 
    }; 
相关问题