Creates an NgModule
for a UIRouter module
This function creates an Angular NgModule with UI-Router support.
var homeState = { name: 'home', url: '/home', component: Home };
var aboutState = { name: 'about', url: '/about', component: About };
@ NgModule({
imports: [
UIRouterModule.forChild({ states: [ homeState, aboutState ] }),
SharedModule,
],
declarations: [ Home, About ],
})
export class AppModule {};
UI-Router module options
an NgModule
Creates a UI-Router Module for the root (bootstrapped) application module to import
This factory function creates an Angular NgModule with UI-Router support.
The forRoot
module should be added to the imports:
of the NgModule
being bootstrapped.
An application should only create and import a single NgModule
using forRoot()
.
All other modules should be created using UIRouterModule.forChild.
Unlike forChild
, an NgModule
returned by this factory provides the [[UIRouter]] singleton object.
This factory also accepts root-level router configuration.
These are the only differences between forRoot
and forChild
.
Example:
let routerConfig = {
otherwise: '/home',
states: [homeState, aboutState]
};
@ NgModule({
imports: [
BrowserModule,
UIRouterModule.forRoot(routerConfig),
FeatureModule1
]
})
class MyRootAppModule {}
browserPlatformDynamic.bootstrapModule(MyRootAppModule);
declarative UI-Router configuration
an NgModule
which provides the [[UIRouter]] singleton instance
Generated using TypeDoc
Creates UI-Router Modules
This class has two static factory methods which create UIRouter Modules. A UI-Router Module is an Angular NgModule with support for UI-Router.
UIRouter Directives
When a UI-Router Module is imported into a
NgModule
, that module's components can use the UIRouter Directives such as UIView, UISref, UISrefActive.State Definitions
State definitions found in the
states:
property are provided to the Dependency Injector. This enables UI-Router to automatically register the states with the [[StateRegistry]] at bootstrap (and during lazy load).Entry Components
Any routed components are added as
entryComponents:
so they will get compiled.