[英]How to stop a call of function before the option's choose in select input
I have a list of products in my select input,what I want is to call the "duplicateGammeProduit" each time I choose a product from the list,that will send the ID of this product,but what I notice is that this method is called before I choose any option,this is my code: 我在选择输入中有一个产品列表,我想要的是每次我从列表中选择一个产品时都调用“ duplicateGammeProduit”,它将发送该产品的ID,但是我注意到的是,这种方法称为在选择任何选项之前,这是我的代码:
<select ng-model="produitId" ng-change="duplicateGammeProduit(produitId)">
<option ng-repeat="pi in listProduitUsed" value="{{pi.id}}">{{pi.reference}}</option>
</select>
and this is the controller code: 这是控制器代码:
.controller(
'GammeCtrl', [
'$scope',
'$http',
function($scope, $http) {
$scope.duplicateGammeProduit = function(produitId) {
$http.get(MyURL:" +produitId).success(
function(gammeProduit) {
//the method to be called when an option is selected
$scope.classifierListElementGamme(gammeProduit.listElementGamme);
gammeProduit.id = null
....
$scope.finalOperationsList = gammeProduit.listElementGamme;
});
}
$scope.listeProduitUsed = function() {
$http
.get(URL/getProduitListUsed")
.success(
function(dataProduit) {
$scope.listProduitUsed = dataProduit;
});}
$scope.listeProduitUsed();
}]);
so how can I stop this call before the option's choose,because this call slows down my app thanks for help 因此,在选择该选项之前,我该如何停止此通话,因为此通话会使我的应用变慢,谢谢
$scope.duplicateGammeProduit = function(produitId) {
if (!produitId) {
return;
}
$http.get(MyURL:" +produitId).success(
function(gammeProduit) {
//the method to be called when an option is selected
$scope.classifierListElementGamme(gammeProduit.listElementGamme);
...
the same idea with my comment 我的评论也一样
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.