我正在编写一个 Angular 4 应用程序,我正在根据一个id值取回一些 JSON到一个 PHP 脚本。我认为在我的代码中,我有一个值被传递到下面的this.PropertiesList中:
examineProperties(id) {
let currentTestIDToFindProperties = this.testScheduleSet[id];
this.allProperty = this.httpClient.get(this.currentTestIDToFindPropertiesUrl + "?testID=" + currentTestIDToFindProperties.value).subscribe((data: any) => {
this.testPropertiesList = data;
console.log("List",this.testPropertiesList);
});
console.log("List After Loop",this.testPropertiesList);
}
我不确定为什么,但我收到了一个响应,其中“List After Loop”的 console.log 出现在“List”console.log 之前,并且显示为undefined,如下所示:
你如何让this.testPropertiesList在订阅功能之外持久化?为什么在“List”之前在控制台中显示“List After Loop”?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句