[英]AngularJS 1.5 ngComponentRouter
The ngNewRouter
(now named ngComponentRouter
) was supposed to be in 1.4, but was delayed and is now supposed to go into 1.5 (as I understand it). ngNewRouter
(现在名为ngComponentRouter
)应该是1.4,但是被推迟了,现在应该进入1.5(据我所知)。 However, it's not in the 1.5 beta2 package . 但是,它不在1.5 beta2包中 。 I do see angular1_router on github , but I don't see that built module included in the 2.0 alpha packages either.
我确实在github上看到angular1_router ,但是我没有看到2.0 alpha包中包含的构建模块。
ngComponentRouter
rather than ngNewRouter
so it's clearly being updated), but the post still has things wrong - like it says to create controllers for the components you're loading for the routes, but I discovered that you actually need to be creating them as directives (optimally using the new "component" wrapper in 1.5) with the restrict set to "A" (that was fun to figure out). ngComponentRouter
而不是ngNewRouter
所以它显然正在更新),但帖子仍然有问题 - 就像它说创建控制器一样您为路由加载的组件,但我发现您实际上需要将它们创建为指令(最佳使用1.5中的新“组件”包装器),并将restrict设置为“A”(这很有趣) )。 You can get the new router via npm with: 您可以通过npm获取新路由器:
npm install @angular/router
For more information on the current API you can have a look at: https://angular.io/docs/js/latest/api/router/Router-class.html 有关当前API的更多信息,请查看: https : //angular.io/docs/js/latest/api/router/Router-class.html
It's for Angular 2 but the core mechanics of the router are the same, and it should give you some hints on how the API has been changed compared to the ngNewRouter. 它适用于Angular 2,但路由器的核心机制是相同的,它应该给你一些关于如何改变API与ngNewRouter相比的提示。
It looks like the component router has been released. 看起来组件路由器已经发布。 Here is the official documentation: https://docs.angularjs.org/guide/component-router
以下是官方文档: https : //docs.angularjs.org/guide/component-router
I'm not seeing any official announcements saying it was released yet though, so I'm not sure if it's supposed to be "official" or not. 我没有看到任何官方声明说它已经发布了,所以我不确定它是否应该是“正式的”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.