gpt4 book ai didi

javascript - 自动完成位置 angularjs 不适用于弹出窗口

转载 作者:行者123 更新时间:2023-11-30 08:25:26 25 4
gpt4 key购买 nike

In my application, I use google location autocomplete to suggest location when I enter some text. without popup then location autocomplete work fine but when I use location autocomplete on a popup then it not working. I use a directive

(function() {
'use strict';

angular
.module('crmApp')
.directive('googleplace', directiveFunction);
directiveFunction.$inject = ['$rootScope'];

function directiveFunction($rootScope) {
return {
require: '?ngModel',
scope: {
ngModel: '=',
details: '=?'
},
link: function(scope, element, attrs, model) {
var options = {
types : ['geocode']
};
scope.gPlace = new google.maps.places.Autocomplete(element[0], options);

google.maps.event.addListener(scope.gPlace, 'place_changed', function() {
scope.$apply(function() {
scope.details = scope.gPlace.getPlace();
model.$setViewValue(element.val());
$rootScope.$broadcast('place_changed', scope.details);
});
});
}
};
}

})();

then I open popup but not working:

<input next-on-enter type="text"  googleplace ng-model="vm.origin" class="form-control" placeholder="Vui lòng nhập xuất xứ"  maxlength="255" name="origin"/>

Screen: google location autocomplete

Help me, please !!!

最佳答案

googleplace directive you write missing something to work. You need modify directive same as example in link: http://plnkr.co/edit/irQiP6waYf5kE6B4NCBe?p=preview

应用自动完成功能的输入更改为:

<input next-on-enter type="text" ng-autocomplete ng-model="vm.origin" options="autoCompleteOptions" details="autoCompleteDetails" class="form-control" placeholder="Vui lòng nhập xuất xứ"  maxlength="255" name="origin"/>

(原帖:https://github.com/angular-ui/bootstrap/issues/693)

关于javascript - 自动完成位置 angularjs 不适用于弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46317125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com