Closed louh closed 11 years ago
@louh haven't looked into this yet, but would it make sense to have two hidden input elements that you bind to instead? then you could have an 'on-click' map event that populates those inputs (which are bound to the controller).
Interesting. This seems like a pretty effective solution; let me give that a try.
...so close. when jQuery updates the input boxes, it doesn't automatically update Angular (only human interaction does that) - there is apparently a way to force Angular to look for changes, but have to look into it more.
@louh want to post your changes to the branch and link to the line of code you're working on? would this work:
jQuery(element).bind('change', function () {
angular.element(element).triggerHandler('change');
})
a little hacky, but it may do the trick.
@rclosner That didn't seem to work. I tried a bunch of other hacky things, like:
Finally I tried various forms of:
THAT WORKED. I was thinking too hard. Essentially, the solution is to also bind a click event to the controller, then, during the callback function, manually assigning the input fields to the model.
Whew!!!!
So I can do something in plain Javascript like this:
Basically, getting Lat/Lng points out of Mapbox/Leaflet is pretty easy. But now, how do I communicate this to an Angular controller?
Most of Angular relies on binding directly to DOM elements via attributes, which would mean interaction with a map element would bypass mapbox.js completely, as far as I understand. I'm not sure I've ever seen anything about how Angular scopes are accessible outside of their controllers, which I imagine would be anti-Angular anyway (because of possible scope pollution).
cc @rclosner