0

i am using angularjs 1.7 and i am trying to display the result of the function using service in the typhead

<input type="text" id="oppId" name="oppId" aria-label="oppId"
       ng-model="oppId"
       typeahead="item for item in commonService.oppIdTypeAhead($viewValue) | limitTo:10"
       ng-blur="checkAndValidate($event)">
oppIdTypeAhead: function (val) {
            var deferred = $q.defer();
            var config = {
                method: "GET",
                headers: { Accept: "application/json" },
                url: constants.oppPickup,
                params: {
                    oppID: val
                },
                timeout: this._getCanceler('OppTypeAhead')
            };

            $http(config).then(function (data) {
                deferred.resolve(data.data);
            }).catch(function (data, status, headers, config) {
                if (status === 0 && data === null) {
                    deferred.reject('canceled');
                } else {
                    deferred.reject(data);
                }
            });
            console.log(deferred.promise);
            return deferred.promise;

this is the result returned by promise

enter image description here

it should display the list of results but then it has an exception of Object doesn't support property or method 'success'

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Icer Exiomo
  • 49
  • 1
  • 9
  • can u share `controller` code ? i cant find `success` in your existing question so I cant debug it. show me the code which is throwing that error and the screenshot of the code please – Shashank Vivek May 24 '19 at 04:20
  • 1
    Avoid the [deferred anti-pattern](https://stackoverflow.com/questions/30750207/is-this-a-deferred-antipattern). Also the signature of the `.catch` method is wrong. See [why was the `.success` method removed from AngularJS](https://stackoverflow.com/questions/35329384/why-are-angularjs-http-success-error-methods-deprecated-removed-from-v1-6/35331339#35331339). – georgeawg May 24 '19 at 05:33

0 Answers0