ngRx 的官方示例演示了在具體的場景中,如何使用 ngRx 管理應用的狀態。
示例介紹
示例允許用戶通過查詢 google 的 book API 來查詢圖書,並保存自己的精選書籍列表。
菜單有兩個菜單項,分別是我的精選和圖書瀏覽。
進入圖書瀏覽頁面后,可以輸入搜索的書名。應用將在線搜索匹配的圖書。
點擊圖書之后,可以得到圖書的詳細信息。如果圖書還沒有被收藏,則提示添加到收藏中。
如果已經添加到收藏中,則變成從收藏中移除。
在我的收藏中,可以看到當前收藏的圖書列表。
示例快速上手
# clone the repo git clone https://github.com/ngrx/example-app.git # change directory to repo cd example-app # Use npm or yarn to install the dependencies: npm install # OR yarn # start the server ng serve
Navigate to http://localhost:4200/ in your browser
下一篇:ngRx 官方示例分析 - 2. Action 管理
參考資源: