Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Return data from angular service #1568


User avatar
0
easyest created

Angular ui typeahead works fine with standard $http promise, but how to make it work with ABP services created from dynamic API? Like here: <a class="postlink" href="http://plnkr.co/edit/izqWaLWM6YkrZXyArrHm?p=preview">http://plnkr.co/edit/izqWaLWM6YkrZXyArrHm?p=preview</a> Documentation says, that "Notice that we registered to success handler (instead of done) since it's like that in angular's $http service", but this is deprecated, please see deprecation notice at <a class="postlink" href="https://docs.angularjs.org/api/ng/service/$http">https://docs.angularjs.org/api/ng/service/$http</a>.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can use it like this

    vm.getUsers = function (val) {
        return userService.getUsers({ filter: val }).then(function (response) {
            return response.data.items.map(function (item) {
                return item.userName;
            });
        });;
    };
    

    in view

    <input type="text" ng-model="selected" uib-typeahead="user for user in vm.getUsersx($viewValue)" class="form-control">