I have a problem with some code:
I want to make a quotation with retrieving three collections items from DB. (function to load are ok).
The first one works, but the next two (which needs data from the first) are not working. It says undefined.
Here is the code:
ngOnInit() {
let id = this.route.snapshot.paramMap.get('id');
this.campaignService.getOneCampaign(id).then(
(campaign: Campaign) => {
this.campaign = campaign;
if (campaign.camptype = "VIDEO") {
this.unitcostvid = (Math.round(this.campaign.unitcost * this.campaign.durationvid * 10000)) / 10000;
this.totalcost = this.unitcostvid * this.campaign.nbuser;
}
if (campaign.camptype = "MAIL") {
this.unitcostvid = this.campaign.unitcost;
this.totalcost = this.unitcostvid * this.campaign.nbuser;
}
if (campaign.status = "EA") {
this.eacamp = true;
}
return this.campaign;
}
)
if (this.campaign) {
this.usercService.getSingleUserc(this.campaign.usercidvalidate).then(
(userc: Userc) => {
this.userc = userc;
return this.userc;
}
)
}
if (this.campaign) {
this.companyService.getCompanybycoid(this.campaign.coid).then(
(company: Company) => {
this.company = company;
return this.company;
}
)
}
}
I want to have campaign
, company
and userc
values, but I only get campaign
Please help me.