从 typescript ionic 2+ 的不同方法获取数据
Getting data from different method on typescript ionic 2+
tryGeolocation(){
this.loading.present();
this.clearMarkers();//remove previous markers
this.geolocation.getCurrentPosition().then((resp) => {
let pos = {
lat: resp.coords.latitude,
lng: resp.coords.longitude
};
let marker = new google.maps.Marker({
position: pos,
map: this.map,
title: 'I am here!'
});
this.markers.push(marker);
this.map.setCenter(pos);
this.loading.dismiss();
}).catch((error) => {
console.log('Error getting location', error);
this.loading.dismiss();
}); }
我想从地理定位中获取纬度和经度数据,并将该数据放入此方法。
openModal() {
const modal = this.modalCtrl.create('ModalPage');
modal.present(); }
怎么样? #我是编程初学者
你必须像
一样通过
const modal = this.modalCtrl.create('ModalPage',{lat:72.33,lng:22.54});
下一页需要像下面这样
constructor(params: NavParams)
{
console.log('lat', params.get('lat'));
console.log('lng', params.get('lng'));
}
更多信息请查看
https://ionicframework.com/docs/api/components/modal/ModalController/
tryGeolocation(){
this.loading.present();
this.clearMarkers();//remove previous markers
this.geolocation.getCurrentPosition().then((resp) => {
let pos = {
lat: resp.coords.latitude,
lng: resp.coords.longitude
};
let marker = new google.maps.Marker({
position: pos,
map: this.map,
title: 'I am here!'
});
this.markers.push(marker);
this.map.setCenter(pos);
this.loading.dismiss();
}).catch((error) => {
console.log('Error getting location', error);
this.loading.dismiss();
}); }
我想从地理定位中获取纬度和经度数据,并将该数据放入此方法。
openModal() {
const modal = this.modalCtrl.create('ModalPage');
modal.present(); }
怎么样? #我是编程初学者
你必须像
一样通过const modal = this.modalCtrl.create('ModalPage',{lat:72.33,lng:22.54});
下一页需要像下面这样
constructor(params: NavParams)
{
console.log('lat', params.get('lat'));
console.log('lng', params.get('lng'));
}
更多信息请查看
https://ionicframework.com/docs/api/components/modal/ModalController/