javascript - Error from google maps API when in an angular directive -
I'm trying to make a simple angular directions which adds Google Maps locations search box for an input. See . I do not need a map, only search box.
command successfully runs (search box object is the console print successful), but I get an error on the console after the run, and input error does not console work Just to make sure, I am using another directive right next to it, with the help of which a date picker was started for jQuery ui. It works fine. HTML: js: Why is there an error? What am i doing wrong The problem is that the element is not in the proper format for callback, you have to do Ankyut is Taiparrr: There is no undefined function .
& lt; Html ng-app = "events" & gt; & Lt; Body & gt; & Lt; H1 & gt; Hello Plunker! & Lt; / H1> Date: & lt; Input type = "text" datetime-input = "format" /> & Lt; Br> Location: & lt; Input type = "text" location-input = "format" /> & Lt; / Body & gt; & Lt; / Html & gt;
var event = angular. Modules ('events', []); Events.directive ( 'locationInput', function () {function link (field element, Etters) {scope.searchbox = new google.maps.places.SearchBox (element); console.log (scope.searchBox);} return { Link: link};}); Events.directive ( 'datetimeInput', function () {function link (scope, elements, Etters) {$ (element) Kdetpikar ();} return {link: link};});
element [0] Later, you must attach a listener. Your code will look something like this:
scope.searchbox = new google.maps.places.SearchBox (element [0]); Google.maps.event.addListener (scope.searchbox, 'places_changed', function () {var places = searchBox.getPlaces () for; (var i = 0, location, location = location [i]; i ++) {Console log (place.icon + ':' + place.name + ':' + place.geometry.location);}}}
Comments
Post a Comment