我在 DIV 中有一个按钮。我正在使用 ng-click 打开两个模式。单击 DIV 时打开一个模态,然后按按钮打开另一个模态
I have a button inside a DIV. I'm using ng-click to open two modal. One modal open when click on the DIV and other by button
我在 DIV 中有一个按钮。我正在使用 ng-click 打开两个模式。单击 DIV 时打开一个模态,单击 button.While 时打开另一个模态,单击 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-click 函数。
$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());
});
};
Modal-2
按钮 ng-click 函数
$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());
});
};
将 $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());
});
};
我在 DIV 中有一个按钮。我正在使用 ng-click 打开两个模式。单击 DIV 时打开一个模态,单击 button.While 时打开另一个模态,单击 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-click 函数。
$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());
});
};
Modal-2 按钮 ng-click 函数
$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());
});
};
将 $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());
});
};