41 lines
1.0 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {PlatformLocation} from '@angular/common';
import {BrowserPlatformLocation} from '@angular/platform-browser';
2016-06-08 11:13:41 -07:00
import {ExtraOptions, provideRouter as provideRouter_} from './common_router_providers';
2016-06-08 11:13:41 -07:00
import {RouterConfig} from './config';
/**
* A list of {@link Provider}s. To use the router, you must add this to your application.
*
* ### Example
*
* ```
* @Component({directives: [ROUTER_DIRECTIVES]})
* class AppCmp {
* // ...
* }
2016-06-08 11:13:41 -07:00
*
* const router = [
2016-06-28 14:49:29 -07:00
* {path: 'home', component: Home}
* ];
*
2016-06-28 14:49:29 -07:00
* bootstrap(AppCmp, [provideRouter(router, {enableTracing: true})]);
* ```
*
* @experimental
*/
export function provideRouter(config: RouterConfig, opts: ExtraOptions = {}): any[] {
return [
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...provideRouter_(config, opts)
];
}