ngComponentRouter

Installation

First include angular-componentrouter.js in your HTML:

<script src="angular.js">
<script src="angular-componentrouter.js">

You can download this file from the following places:

  • Google CDN
    e.g. //ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-componentrouter.js
  • Bower
    e.g.
    bower install angular-componentrouter@X.Y.Z
  • code.angularjs.org
    e.g.
    "//code.angularjs.org/X.Y.Z/angular-componentrouter.js"

where X.Y.Z is the AngularJS version you are running.

Then load the module in your application by adding it as a dependent module:

angular.module('app', ['ngComponentRouter']);

With that you're ready to get started!

The new Angular Router

Module Components

Type

Name Description
Router

A Router is responsible for mapping URLs to components.

ChildRouter

This type extends the Router.

RootRouter

This type extends the Router.

ComponentInstruction

A ComponentInstruction represents the route state for a single component. An Instruction is composed of a tree of these ComponentInstructions.

RouteDefinition

Each item in a the RouteConfig for a Routing Component is an instance of this type. It can have the following properties:

RouteParams

A map of parameters for a given route, passed as part of the ComponentInstruction to the Lifecycle Hooks, such as $routerOnActivate and $routerOnDeactivate.

Directive

Name Description
ngOutlet

The directive that identifies where the Router should render its Components.

Service

Name Description
$rootRouter

The singleton instance of the RootRouter type, which is associated with the top level $routerRootComponent.

$routerRootComponent

The top level Routing Component associated with the $rootRouter.

doc_AngularJS
2016-03-29 16:11:42
Comments
Leave a Comment

Please login to continue.