我想将一个 ember 组件传递给另一个 ember 组件 ( lat
) 。我的车把模板:lng
g-map
{{!-- 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>
{{text-autocomplete}}
<p class="lead">
<button class="btn btn-primary btn-default" href="#" role="button" disabled={{isDisabled}}>Search</button>
</p>
</div>
{{g-map lat=lat lng=lng zoom=zoom}}
</div>
这是我的文本自动完成组件:
// 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();
});
}
});
我想将组件中的和值传递给lat
组件lng
以在谷歌地图中绘制标记。text-autocomplete
g-map
谁能解决这个问题?:(