如何解决这个问题?
服务
getInfoAccountById(id: any) {
this.module = 'accounts/' + id + '/infos';
let headers = new Headers();
headers.append(this.key, this.token);
return this.http.get(this.url + this.module, {
headers
}).map(res => res.json().Result)
}
主页nav params
constructor(public navCtrl: NavController, public navParams: NavParams, public acc: AccountService) {
this.navParams = navParams;
this.dataDetails = {
id: this.navParams.get('data').Id,
name: this.navParams.get('data').Identification,
complement: this.navParams.get('data').Complement,
account: this.navParams.get('data').AccountType.Identification,
pricelist: this.navParams.get('data').PriceList,
active: this.navParams.get('data').Active,
color:this.acc.getdetailsAccountById(this.navParams.get('data').Id).subscribe(data => { this.datad = data.Color; }),
informations:this.acc.getInfoAccountById(this.navParams.get('data').Id) // this line have a problem
};
}
辅助页面接收了参数
constructor(public navCtrl: NavController, public navParams: NavParams, public acc: AccountService, public http: Http) {
this.id = this.navParams.data.id;
this.name = this.navParams.data.name;
this.complement = this.navParams.data.complement;
this.account = this.navParams.data.account;
this.pricelist = this.navParams.data.pricelist;
this.active = this.navParams.data.active;
this.color = this.navParams.data.color;
this.infos = this.navParams.data.informations;
console.log(this.infos);
}
答案 0 :(得分:0)
您必须在订阅中进行设置。
constructor(public navCtrl: NavController, public navParams: NavParams, public acc: AccountService) {
this.navParams = navParams;
this.dataDetails = {
id: this.navParams.get('data').Id,
name: this.navParams.get('data').Identification,
complement: this.navParams.get('data').Complement,
account: this.navParams.get('data').AccountType.Identification,
pricelist: this.navParams.get('data').PriceList,
active: this.navParams.get('data').Active,
color:'',
information:''
};
this.acc.getdetailsAccountById(this.navParams.get('data').Id).subscribe(data => { this.dataDetails.color = data.Color; })
this.acc.getInfoAccountById(this.navParams.get('data').Id).subscribe(data=> this.dataDetails.information = data;
}