Angular2 - Elevator Event Fire Event

I am trying to use a leaflet with Angular 2 TS for my Ionic 2 application. I want to release pinClicked -event when I click the leaflet. How to do it? In Angular1 $ scope. $ Apply was the solution ...

private refreshMarkers() {
    L.marker([40.731253, -73.996139])
      .addTo(this.map)
      .on('click', function() { alert('JA'); } );
  }

  private pinWasClicked() {
    this.pinClicked.emit('');
  }
+4
source share
1 answer

try it

private refreshMarkers() {
let marker=L.marker([40.731253, -73.996139]);
  marker.addTo(this.map);
  marker.on('click', 
             (e)=>
             {this.pinWasCliscked(e)} );
}
private pinWasClicked(e) {
console.log(e);
this.pinClicked.emit('');
}
+1
source

Source: https://habr.com/ru/post/1648715/


All Articles