【发布时间】:2020-05-11 00:03:22
【问题描述】:
这个带有get/http/subscribe的函数没有返回正确的值,它返回undefined,为什么?`
function_one() {
let text = this.getData();
console.log(' Here text is undefined --> ', text);
}
getData() {
this.http.get("assets/img/tutorial/tutorialenus.JSON").subscribe
(response => {
console.log(' Here response = The simple text', response);
return response;
}
);
}
【问题讨论】:
-
getData()中没有返回语句,您从订阅回调返回response。 -
谢谢你们 - 我阅读了所有的帖子并为我工作
标签: json angular typescript ionic-framework