Answer the question
In order to leave comments, you need to log in
How to connect Angular and Yandex maps?
The problem is that when adding to Yandex.maps, tracking changes does not work for events with Yandex.maps (for example, clicking on the map with determining the coordinates where you clicked, with further determining the address).
There is a component, it has a map and an input for displaying the address. When you click on the map, coordinates are determined, geocoded, the model changes, and it is expected that a geocoded address will appear in the input.
Judging by the debug, everything is going right until the model is changed, but the address does not appear in the input (and if you focus / blur on the input, the address will appear).
Removing the map into a separate component, and passing the address through the EventEmitter and emit does not work - everything works the same way until the model changes, but the view is not updated.
Why can this be?
Answer the question
In order to leave comments, you need to log in
The jamb is that the events tied to the map
this.myMap.events.add('click' function(e){...}.bind(this))
this.changeDetection.detectChanges()
import { ... NgZone ... } from '@angular/core';
constructor(... public zone: NgZone ...) { ... }
this.myMap.events.add('click', function (e) {
this.zone.run(() => {
... // <- всё что будет написано тут выполнится внутри ангулара и его контекста, и вызовет ожидаемое изменение view
}.bind(this));
According to the first signs, the model is not tied up correctly in the input. You must specify ([ngModel])="yourModelInTyscript"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question