angular - @ngrx/router-store 对比@angular/router

标签 angular angular2-routing ngrx

使用 @ngrx/router-store 有哪些优点和缺点?而不是 @angular/router

最佳答案

这是与现已弃用的 beta 路由器的比较 https://gitter.im/ngrx/store?at=5710e4fc5cd40114649b9399

the main differences between the component router and ngrx/router are the decisions behind the design. The component router takes a more internal approach when it comes to components if you look at the lifecycle hooks. Our router doesn’t require that the router hook into your components so any component is routable. Another difference is the use of observables. The component router uses promises to handle its lifecycle, whereas ours uses observables because they lend themselves to more of a reactive approach. Our route/query parameters are observable which makes reusing components when parameters change easier. Our router has more streams available for you to subscribe to and react upon. The overall idea is that the browser URL itself is a stream and we are turning that stream into a view of rendered routes. Both routers have a concept of lazy loading, protecting routes, resolving data and lifecycle events. Both still have gaps that need to be filled. If you prefer a more observable approach, our router works very nicely with that.

新的 angular2 路由器将更接近今天的 ngrx/router,所以如果您现在使用已弃用的 beta 路由器,请继续使用它直到新路由器发布然后迁移。如果您是白手起家,我会说使用 ngrx/router,因为它提供了一个相对容易的迁移路径,可以在新路由器准备就绪后迁移到新路由器。

关于angular - @ngrx/router-store 对比@angular/router,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37621037/

相关文章:

angular - 确保在测试中填充了 ngrx 存储

javascript - 无论单击“确定”还是“取消”,我的确认弹出窗口仍在删除对象。为什么? Angular 怪?

javascript - Ionic 4 使用自定义图标更改 ion-tab-button

javascript - 找不到主要导出来加载 Angular 2

angular - 从 angular2 中的指令访问路由数据

angular - @ngrx/effects API 请求处理

Angular NgRx - 在效果中使用 store.dispatch 是不好的做法吗?

angular - 寻找具有动态表单下拉选项的自定义下拉列表的解决方案

angularjs - Angular 2 : Inject view/DOM into component constructor

angular - 在 Angular 2 中强制路由转换为具有不同参数的相同路由