Closed caioiglesias closed 8 years ago
Using $timeout
would be the best way, it's a safe-$apply()
call in effect (the way you're intending to use it). Would be interested to see the code though to see if there's a better way :)
Thank you. It's already clear enough, but I will provide a leaflet/angular sample
I see the shame woman behind me
Changes to a statefull parent component don't propagate down to the stateless component immediately when using an external library, because things happened outside angular, so changes only apply on the next eventual digest cycle. The only workaround I see to actually not go for a $scope injection and an $apply() is actually wrapping a $q promise and resolving or wrapping the change in a $timeout.
I have seen this when using an external library in a service injected in a statefull component, such as firebase (and they recommend $timeout), or passing an event from a stateless child component to a parent's statefull component using an event from a library such as leaflet.
Is there an alternative to these $q / $timeout practices?