lundi 13 mars 2017

send value from ember component to parent template

i wanna passing lat & lng from ember component to g-map component in ember. this is my code

  Index.hbs
  <div class="jumbotron-outside">
  <div class="jumbotron">
    <h1 class="display-3">See The Weather Outside :)</h1>
    <p class="lead">This is a simple forecast weather.</p>
    <hr class="my-4">
    <p>Just type everything bellow this input text to get all list of the city</p>
    
    <p class="lead">
      <button class="btn btn-primary btn-default" href="#" role="button" disabled=>Search</button>
    </p>
  </div>
  
</div>

and this is for my text-autocomplete component.js

import Ember from 'ember';

let lat;
let lng;
export default Ember.Component.extend({
    didInsertElement() { //dom can be acessed here :)
        var autocomplete = new google.maps.places.Autocomplete($('input')[0]);
        var parent = this.$('input');
        google.maps.event.addListener(autocomplete, 'place_changed', function() {
            var place = autocomplete.getPlace();
            lat = place.geometry.location.lat();
            lng = place.geometry.location.lng();
        });
    }
});

i just wanna passs the lat lng value from text-autocomplete component to the g-map component (ember-g-map) to draw a marker in the google map. can anyone solve this? :(




Aucun commentaire:

Enregistrer un commentaire