[英]What is the best way to read the db or rest api object in angular framework?
I am experienced java developer and recently working on angular as well, most of the time i use observable<any>
as a return type of my http api method or db read method but what is the best way to do this to avoid [ object, object] read error
或object is undefined
。
我會很感激你的幫助。 謝謝
getComments(): Observable<any> {
return this.http.get(environment.api + '/payments/6');
}
addComments(body): Observable<any> {
console.log(body);
return this.http.post(environment.api + '/payments/account', body);
} ```
在 Angular 中,通過插值,Angular 執行以下任務:
Your problem is with section two, when you pass an object to interpolation, Angular converts object to string and the result will be [object Object]
, so you have to pass some primitives or use json
pipe to interpolate correctly.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.