如何在批量自动完成时停止ajax调用?

时间:2016-08-03 10:31:17

标签: javascript angularjs

<input type="text" ng-model="clientName" ng-mass-autocomplete-item="getClients">

Controller.js:

     $scope.getAgencies = {
                            suggest: suggest_Agencies,
                            debounce_suggest: 600,
                            debounce_blur: 500,
                            on_select: function (selected_item) {
                                $scope.agencyName = selected_item.value;
                            },
                        };
                        function suggest_Agencies(agencyName) {
                            $scope.agencies = [];
                            $scope.agencyName = agencyName;
                            var params = {"agencyName": agencyName};
                            ajaxcalls.ajaxPostRequest('catalog/getAgencies', params, function (response) {
                                var agencies = response.data;
                                if (agencies != null && agencies.length > 0) {
                                    agencies.forEach(function (item, index) {
                                        $scope.agencies.push({label: item.AgencyName, value: item.AgencyName});
                                    });
                                }
                            }, "noSpinner", false);
        /** here false argument means asynchronous set to false. */
                            return $scope.agencies;
                        }

这是link

我该如何解决这个问题?我想通过这个指令获得建议,并在输入时停止ajax调用。

0 个答案:

没有答案