Angular UI Bootstrap Typeahead什么都不做

时间:2014-11-19 20:57:28

标签: angularjs angular-ui-bootstrap

Angular JS - v1.2.0-rc.3 Angular Bootstrap - 0.12.0

控制器:

app.controller('controlsController', ['$scope', '$http', function($scope, $http) {

    $scope.selected = undefined;

    $scope.getLocation = function(val) {
        return $http.get('http://maps.googleapis.com/maps/api/geocode/json', {
            params: {
                address: val,
                sensor: false
            }
        }).success(function(response){
            return response.data.results.map(function(item){
                return item.formatted_address;
            });
        });
    };
}]);

玉:

input(type='text'
        ng-model='asyncSelected'
        placeholder='find...'
        typeahead='address for address in getLocation($viewValue)'
        typeahead-loading='loadingLocations'
        class='form-control')

结果:

  

没有

我尝试使用调用getLocation的按钮代替输入,然后调用函数OK。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

  1. 您不需要ui-bootstrap-tpls.min.js ui-bootstrap.min.js。无论是其中一个。

  2. 请记住将依赖项添加到应用程序的模块中。

        var app = angular.module('myApp', ['ui.bootstrap']);