Angularjs使用json数据自动完成打印头

时间:2015-11-27 15:26:41

标签: ruby-on-rails angularjs json

在我的html页面中定义控制器和ng-app之后,我使用了angularjs typehead来实现自动完成功能。

HTML

<input type="text" ng-model="selected" uib-typeahead="location for location getLocation($viewValue)" typeahead-loading="loadingLocations" typeahead-no-results="noResults" class="form-control" placeholder="json data">
<i ng-show="loadingLocations" class="glyphicon glyphicon-refresh"></i>
<div ng-show="noResults">
    <i class="glyphicon glyphicon-remove"></i> No Results Found
</div>

的JavaScript

$scope.getLocation = val => {

    return $http.get('./resultlocation.json', {
        params: {
            address: val
        }
    }).then(response => {
        return response(item => item.name);
    });

};

0 个答案:

没有答案