现在我设法从我的 PHP-API 获取 DB-Data。现在我正在努力将它从我的服务发送到我的page.ts
. 不知何故,它一直未定义。
服务:
getData(dbargument:String) {
var headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
let fullheader = new HttpHeaders( headers );
let postData = dbargument;
let postDataJson = JSON.stringify(postData);
let header = new HttpHeaders();
let real_header : any = header.append('Content-Type', 'application/x-www-form-urlencoded');
this.http_post.post('URL is set here', postDataJson, real_header).subscribe(data => {
console.log("JSONSTRING: " + JSON.stringify(data));
return data;
});
}
页面.ts:
ngOnInit() {
/* Calling Data on Page load */
this.platform.ready().then(() => {
this.getActiveJobs();
console.log('Post initialized');
});
}
getActiveJobs() {
this.activeJobsID = this.activeJobs.userid;
this.activeJobsStr = "//Working SQL Statement is here";
this.activeJobsCount = this.activeJobs.getData(this.activeJobsStr);
console.log('Post worked');
console.log(this.activeJobsID);
}
我试图获取值的变量是activeJobsCount
.
提前致谢!
编辑:
当前问题 1
编辑2:
看起来问题出在以下部分:
this.http_post.post('http://kfz-expertus-portal.de/API/dbpost.php', postDataJson, real_header).subscribe(result => {
console.log("JSONSTRING: " + result);
return result;
});
the JSONSTRING is shown in the logs but i cant return the result to the page.ts