简体   繁体   中英

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). However, it's not in the 1.5 beta2 package . I do see angular1_router on github , but I don't see that built module included in the 2.0 alpha packages either.

  1. Does anyone know if the new router will actually be in the 1.5 release?
  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).
  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).

You can get the new router via npm with:

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

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.

It looks like the component router has been released. Here is the official documentation: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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