簡體   English   中英

在 ZD18B8624A0F5F5721ZDDFC82 框架中讀取 db 或 rest api object 的最佳方法是什么?

[英]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 errorobject 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 執行以下任務:

  1. 計算雙花括號中的所有表達式。
  2. 將表達式結果轉換為字符串
  3. 將結果鏈接到任何相鄰的文字字符串。
  4. 將組合分配給元素或指令屬性

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM