AngularUI-Bootstrap's Typeahead Can't Read `length` Property of `undefined`

前端 未结 3 743
时光取名叫无心
时光取名叫无心 2020-12-31 03:07

I am getting the following error when I attempt to get a typeahead values from AngularUI-Bootstrap, using a promise.

TypeError: Cannot read property \'length         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 03:32

    $scope.getTypeaheadValues = function($viewValue)
    {
        var someOutput="";//return something
    
        $http({
            method: 'GET',
            url: 'api/v1/person?name__icontains=' + $viewValue
        }).error(function (data) {
            console.error(data);
        }).success(function (data) {
            console.log(data);//Do whatever you want 
        });
    return someOutput;
    

    }

    //The return statement is missing

提交回复
热议问题