Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).
like image 930
TheDruidsKeeper Avatar asked Nov 24 '15 18:11

TheDruidsKeeper


People also ask

What is Oninit in AngularJS?

OnInitlinkA lifecycle hook that is called after Angular has initialized all data-bound properties of a directive.

What is stateProvider in AngularJS?

$stateProvider is used to define different states of one route. You can give the state a name, different controller, different view without having to use a direct href to a route. There are different methods that use the concept of $stateprovider in AngularJS.

How do I register a component in AngularJS?

Components can be registered using the . component() method of an AngularJS module (returned by angular. module() ).

What are bindings in AngularJS?

Data binding in AngularJS is the synchronization between the model and the view. When data in the model changes, the view reflects the change, and when data in the view changes, the model is updated as well.


1 Answers

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.

like image 80
Stefan Leye Avatar answered Oct 20 '22 04:10

Stefan Leye