2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
|
2016-06-08 17:46:02 -07:00
|
|
|
import {PlatformLocation} from '@angular/common';
|
|
|
|
import {BrowserPlatformLocation} from '@angular/platform-browser';
|
2016-06-08 11:13:41 -07:00
|
|
|
|
2016-06-22 14:56:10 -07:00
|
|
|
import {ExtraOptions, provideRouter as provideRouter_} from './common_router_providers';
|
2016-06-08 11:13:41 -07:00
|
|
|
import {RouterConfig} from './config';
|
|
|
|
|
2016-05-27 13:51:14 -07:00
|
|
|
|
|
|
|
/**
|
2016-06-08 17:46:02 -07:00
|
|
|
* A list of {@link Provider}s. To use the router, you must add this to your application.
|
2016-05-27 13:51:14 -07:00
|
|
|
*
|
|
|
|
* ### Example
|
|
|
|
*
|
|
|
|
* ```
|
|
|
|
* @Component({directives: [ROUTER_DIRECTIVES]})
|
|
|
|
* class AppCmp {
|
|
|
|
* // ...
|
|
|
|
* }
|
2016-06-08 11:13:41 -07:00
|
|
|
*
|
2016-06-08 17:46:02 -07:00
|
|
|
* const router = [
|
2016-06-28 14:49:29 -07:00
|
|
|
* {path: 'home', component: Home}
|
2016-05-27 13:51:14 -07:00
|
|
|
* ];
|
|
|
|
*
|
2016-06-28 14:49:29 -07:00
|
|
|
* bootstrap(AppCmp, [provideRouter(router, {enableTracing: true})]);
|
2016-05-27 13:51:14 -07:00
|
|
|
* ```
|
2016-06-27 12:27:23 -07:00
|
|
|
*
|
|
|
|
* @experimental
|
2016-05-27 13:51:14 -07:00
|
|
|
*/
|
2016-06-22 14:56:10 -07:00
|
|
|
export function provideRouter(config: RouterConfig, opts: ExtraOptions = {}): any[] {
|
2016-05-27 13:51:14 -07:00
|
|
|
return [
|
2016-06-22 14:56:10 -07:00
|
|
|
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...provideRouter_(config, opts)
|
2016-05-27 13:51:14 -07:00
|
|
|
];
|
|
|
|
}
|