angular-ui / angular-google-maps

AngularJS directives for the Google Maps Javascript API
http://angular-ui.github.io/angular-google-maps
2.52k stars 1.07k forks source link

Events handled in non angular way #241

Closed digitalgym closed 10 years ago

digitalgym commented 10 years ago

I'm noticing that events assigned to the events:{} bag require the apply() call. Why are events being called in a non-angular fashion like this.

nmccready commented 10 years ago

Because you have a direct hook to the google map sdk right there. That event is not angular at all. Therefore it has no dirty checking around it. Therefore apply is required.

nlaplante commented 10 years ago

Added an entry in the FAQ

jmcomets commented 10 years ago

IMO, it doesn't make a lot of sense here to require the $scope.apply to be called, it should be wrapped by the directive.

nlaplante commented 10 years ago

Leaving this to the developer leaves more room for customization on how and when $apply is called. Wrapping this in the directive removes this freedom. Again, see $apply docs

nmccready commented 10 years ago

I totally agree with @nlaplante , there are times where you do not want to use $apply for performance reasons. Plus there is no way for our directive to know when the event has been passed to you. You have a direct hook to the google maps API on the events property.

nmccready commented 10 years ago

Examples would be silent changes or making more json requests based off the event. In that example you would not be needing apply at all (until after the JSON callback is done).

jmcomets commented 10 years ago

Ok, it just sux to have this duplicated in every one of my events. :/

2014-03-18 14:30 GMT+01:00 nmccready notifications@github.com:

Examples would be silent changes or making more json requests based off the event. In that example you would not be needing apply at all (until after the JSON callback is done).

Reply to this email directly or view it on GitHubhttps://github.com/nlaplante/angular-google-maps/issues/241#issuecomment-37932049 .

[image: INSA de Lyon] Jean-Marie Comets Élève Ingénieur - INSA de Lyon jean.marie.comets@insa-lyon.fr jean.marie.comets@insa-lyon.fr tél: +33(0)699659407

nmccready commented 8 years ago

Yeah a work around would be to implement something like ui-leaflet using rootScope or scope to pass events around via $on but that modification will require a major PR from someone else.