Answer the question
In order to leave comments, you need to log in
How to attach yandex suggest view to angular?
<input type="text"
class="form-control"
id="suggest"
placeholder="Адрес"
ng-model="suggest"
>
{{ suggest }}
<script src="//api-maps.yandex.ru/2.1/?lang=ru_RU&load=SuggestView&onload=onLoad"></script>
<script>
function onLoad (ymaps) {
var suggestView = new ymaps.SuggestView('suggest');
}
</script>
Answer the question
In order to leave comments, you need to log in
function yandexSuggestViewDirective () {
return {
restrict: 'A',
require: [ 'ngModel' ],
scope: { ngModel: '=' },
link: function (scope, element) {
ymaps.ready(function () {
new ymaps.SuggestView(element[0]).events.add('select', function (e) {
scope.$apply(function () {
scope.ngModel = e.get('item').value;
});
});
})
}
};
}
<input class="form-control" placeholder="Адрес" ng-model="suggest" yandex-suggest-view />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question