docs(router): update the docs of LocationPathStrategy
This commit is contained in:
parent
0668ba50e8
commit
e1109d52e1
|
@ -25,44 +25,17 @@ import {PlatformLocation, UrlChangeListener} from './platform_location';
|
||||||
* `PathLocationStrategy` is the default binding for {@link LocationStrategy}
|
* `PathLocationStrategy` is the default binding for {@link LocationStrategy}
|
||||||
* provided in {@link ROUTER_PROVIDERS}.
|
* provided in {@link ROUTER_PROVIDERS}.
|
||||||
*
|
*
|
||||||
* If you're using `PathLocationStrategy`, you must provide a provider for
|
* If you're using `PathLocationStrategy`, you must provide a {@link APP_BASE_HREF}
|
||||||
* {@link APP_BASE_HREF} to a string representing the URL prefix that should
|
* or add a base element to the document. This URL prefix that will be preserved
|
||||||
* be preserved when generating and recognizing URLs.
|
* when generating and recognizing URLs.
|
||||||
*
|
*
|
||||||
* For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
|
* For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
|
||||||
* `location.go('/foo')`, the browser's URL will become
|
* `location.go('/foo')`, the browser's URL will become
|
||||||
* `example.com/my/app/foo`.
|
* `example.com/my/app/foo`.
|
||||||
*
|
*
|
||||||
* ### Example
|
* Similarly, if you add `<base href='/my/app'/>` to the document and call
|
||||||
*
|
* `location.go('/foo')`, the browser's URL will become
|
||||||
* ```
|
* `example.com/my/app/foo`.
|
||||||
* import {Component} from '@angular/core';
|
|
||||||
* import {bootstrap} from '@angular/platform-browser/browser';
|
|
||||||
* import {
|
|
||||||
* Location,
|
|
||||||
* APP_BASE_HREF
|
|
||||||
* } from '@angular/common';
|
|
||||||
* import {
|
|
||||||
* ROUTER_DIRECTIVES,
|
|
||||||
* ROUTER_PROVIDERS,
|
|
||||||
* RouteConfig
|
|
||||||
* } from '@angular/router';
|
|
||||||
*
|
|
||||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
|
||||||
* @RouteConfig([
|
|
||||||
* {...},
|
|
||||||
* ])
|
|
||||||
* class AppCmp {
|
|
||||||
* constructor(location: Location) {
|
|
||||||
* location.go('/foo');
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* bootstrap(AppCmp, [
|
|
||||||
* ROUTER_PROVIDERS, // includes binding to PathLocationStrategy
|
|
||||||
* {provide: APP_BASE_HREF, useValue: '/my/app'}
|
|
||||||
* ]);
|
|
||||||
* ```
|
|
||||||
*
|
*
|
||||||
* @stable
|
* @stable
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue