简体   繁体   English

AngularJS 1.5 ngComponentRouter

[英]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包中包含的构建模块。

  1. Does anyone know if the new router will actually be in the 1.5 release? 有谁知道新的路由器是否真的会在1.5版本中?
  2. Is there a current build of the new router hosted anywhere? 是否有当前构建的新路由器托管在任何地方? I managed to find a copy of the compiled js from a random plunker, but haven't been able to compile the source myself (issues with node-gyp & msbuild, still working on that). 我设法从一个随机的plunker中找到了编译的js的副本,但是我自己无法编译源代码(node-gyp和msbuild的问题,仍然在研究它)。
  3. Does anyone know of any up-to-date documentation or working samples on the new component router? 有没有人知道新组件路由器上的任何最新文档或工作样本? The best site I've found so far is pretty close (it says it was published in February, but it uses 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). 到目前为止我发现最好的网站非常接近(它说它是在2月份发布的,但它使用了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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM