2017-02-11 97 views
0

store.select(「書籍」)是可觀察到的,並且在下面代碼打印無法觀察到的循環

{ "books": [ { "id": 1, "title": "title here1", "description": "desc here1", "author": "test", "price": 99 }, { "id": 2, "title": "title here2", "description": "desc here2", "author": "test", "price": 99 } ] } 

查閱「STEP 1」,我想通過書籍陣列循環,爲此,我寫了「STEP 2」,但它沒有打印任何東西。 需要修改哪些內容才能使* ngFor工作?

<!-- STEP 1 --> 
{{store.select('books') | async | json}} 


<!-- STEP 2 --> 
<ul> 
    <li *ngFor="let book of store.select('books').books | async"> 
     {{book.title}} &nbsp;&nbsp;&nbsp;&nbsp; {{book.price}} 
    </li> 
</ul> 
+0

試試這個:'讓書(store.select('books')| async)?.書籍' –

+0

是的,它已經工作.. – refactor

回答

1

試試這個:

let book of (store.select('books') | async)?.books 

因爲你store.select('books')是一個async過程不store.select('books').books

我在?之後確認此聲明的迴應不是falsy的值。