@ -18,7 +18,7 @@ import {EventListener, History, Location} from 'angular2/src/core/facade/browser
|
||||
* import {Component, View} from 'angular2/angular2';
|
||||
* import {
|
||||
* ROUTER_DIRECTIVES,
|
||||
* ROUTER_BINDINGS,
|
||||
* ROUTER_PROVIDERS,
|
||||
* RouteConfig,
|
||||
* Location
|
||||
* } from 'angular2/router';
|
||||
@ -34,7 +34,7 @@ import {EventListener, History, Location} from 'angular2/src/core/facade/browser
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, [ROUTER_BINDINGS]);
|
||||
* bootstrap(AppCmp, [ROUTER_PROVIDERS]);
|
||||
* ```
|
||||
*/
|
||||
@Injectable()
|
||||
|
@ -16,7 +16,7 @@ import {Url} from './url_parser';
|
||||
*
|
||||
* ```
|
||||
* import {bootstrap, Component, View} from 'angular2/angular2';
|
||||
* import {Router, ROUTER_DIRECTIVES, ROUTER_BINDINGS, RouteConfig} from 'angular2/router';
|
||||
* import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
||||
*
|
||||
* @Component({...})
|
||||
* @View({directives: [ROUTER_DIRECTIVES]})
|
||||
@ -34,7 +34,7 @@ import {Url} from './url_parser';
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, ROUTER_BINDINGS);
|
||||
* bootstrap(AppCmp, ROUTER_PROVIDERS);
|
||||
* ```
|
||||
*/
|
||||
export class RouteParams {
|
||||
@ -54,7 +54,7 @@ export class RouteParams {
|
||||
*
|
||||
* ```
|
||||
* import {bootstrap, Component, View} from 'angular2/angular2';
|
||||
* import {Router, ROUTER_DIRECTIVES, ROUTER_BINDINGS, RouteConfig} from 'angular2/router';
|
||||
* import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
||||
*
|
||||
* @Component({...})
|
||||
* @View({directives: [ROUTER_DIRECTIVES]})
|
||||
@ -68,7 +68,7 @@ export class RouteParams {
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, ROUTER_BINDINGS);
|
||||
* bootstrap(AppCmp, ROUTER_PROVIDERS);
|
||||
* ```
|
||||
*/
|
||||
export class Instruction {
|
||||
|
@ -9,7 +9,7 @@ import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/src/core/di';
|
||||
* The `APP_BASE_HREF` token represents the base href to be used with the
|
||||
* {@link PathLocationStrategy}.
|
||||
*
|
||||
* If you're using {@link PathLocationStrategy}, you must provide a binding to a string
|
||||
* If you're using {@link PathLocationStrategy}, you must provide a provider to a string
|
||||
* representing the URL prefix that should be preserved when generating and recognizing
|
||||
* URLs.
|
||||
*
|
||||
@ -17,7 +17,7 @@ import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/src/core/di';
|
||||
*
|
||||
* ```
|
||||
* import {Component, View} from 'angular2/angular2';
|
||||
* import {ROUTER_DIRECTIVES, ROUTER_BINDINGS, RouteConfig} from 'angular2/router';
|
||||
* import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
||||
*
|
||||
* @Component({...})
|
||||
* @View({directives: [ROUTER_DIRECTIVES]})
|
||||
@ -29,9 +29,9 @@ import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/src/core/di';
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, [
|
||||
* ROUTER_BINDINGS,
|
||||
* ROUTER_PROVIDERS,
|
||||
* PathLocationStrategy,
|
||||
* bind(APP_BASE_HREF).toValue('/my/app')
|
||||
* provide(APP_BASE_HREF, {asValue: '/my/app'})
|
||||
* ]);
|
||||
* ```
|
||||
*/
|
||||
@ -59,7 +59,7 @@ export const APP_BASE_HREF: OpaqueToken = CONST_EXPR(new OpaqueToken('appBaseHre
|
||||
* import {Component, View} from 'angular2/angular2';
|
||||
* import {
|
||||
* ROUTER_DIRECTIVES,
|
||||
* ROUTER_BINDINGS,
|
||||
* ROUTER_PROVIDERS,
|
||||
* RouteConfig,
|
||||
* Location
|
||||
* } from 'angular2/router';
|
||||
@ -75,7 +75,7 @@ export const APP_BASE_HREF: OpaqueToken = CONST_EXPR(new OpaqueToken('appBaseHre
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, [ROUTER_BINDINGS]);
|
||||
* bootstrap(AppCmp, [ROUTER_PROVIDERS]);
|
||||
* ```
|
||||
*/
|
||||
@Injectable()
|
||||
@ -91,7 +91,7 @@ export class Location {
|
||||
|
||||
if (isBlank(browserBaseHref)) {
|
||||
throw new BaseException(
|
||||
`No base href set. Either provide a binding for the APP_BASE_HREF token or add a base element to the document.`);
|
||||
`No base href set. Either provide a provider for the APP_BASE_HREF token or add a base element to the document.`);
|
||||
}
|
||||
|
||||
this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
|
||||
|
@ -10,9 +10,9 @@ import {LocationStrategy} from './location_strategy';
|
||||
* browser's URL.
|
||||
*
|
||||
* `PathLocationStrategy` is the default binding for {@link LocationStrategy}
|
||||
* provided in {@link ROUTER_BINDINGS}.
|
||||
* provided in {@link ROUTER_PROVIDERS}.
|
||||
*
|
||||
* If you're using `PathLocationStrategy`, you must provide a binding for
|
||||
* If you're using `PathLocationStrategy`, you must provide a provider for
|
||||
* {@link APP_BASE_HREF} to a string representing the URL prefix that should
|
||||
* be preserved when generating and recognizing URLs.
|
||||
*
|
||||
@ -23,11 +23,11 @@ import {LocationStrategy} from './location_strategy';
|
||||
* ## Example
|
||||
*
|
||||
* ```
|
||||
* import {Component, View, bind} from 'angular2/angular2';
|
||||
* import {Component, View, provide} from 'angular2/angular2';
|
||||
* import {
|
||||
* APP_BASE_HREF
|
||||
* ROUTER_DIRECTIVES,
|
||||
* ROUTER_BINDINGS,
|
||||
* ROUTER_PROVIDERS,
|
||||
* RouteConfig,
|
||||
* Location
|
||||
* } from 'angular2/router';
|
||||
@ -44,8 +44,8 @@ import {LocationStrategy} from './location_strategy';
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, [
|
||||
* ROUTER_BINDINGS, // includes binding to PathLocationStrategy
|
||||
* bind(APP_BASE_HREF).toValue('/my/app')
|
||||
* ROUTER_PROVIDERS, // includes binding to PathLocationStrategy
|
||||
* provide(APP_BASE_HREF, {asValue: '/my/app'})
|
||||
* ]);
|
||||
* ```
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptio
|
||||
|
||||
import {Directive, Attribute} from 'angular2/src/core/metadata';
|
||||
import {DynamicComponentLoader, ComponentRef, ElementRef} from 'angular2/src/core/linker';
|
||||
import {Injector, bind, Dependency} from 'angular2/src/core/di';
|
||||
import {Injector, provide, Dependency} from 'angular2/src/core/di';
|
||||
|
||||
import * as routerMod from './router';
|
||||
import {ComponentInstruction, RouteParams} from './instruction';
|
||||
@ -50,13 +50,12 @@ export class RouterOutlet {
|
||||
var componentType = nextInstruction.componentType;
|
||||
var childRouter = this._parentRouter.childRouter(componentType);
|
||||
|
||||
var bindings = Injector.resolve([
|
||||
bind(ROUTE_DATA)
|
||||
.toValue(nextInstruction.routeData()),
|
||||
bind(RouteParams).toValue(new RouteParams(nextInstruction.params)),
|
||||
bind(routerMod.Router).toValue(childRouter)
|
||||
var providers = Injector.resolve([
|
||||
provide(ROUTE_DATA, {asValue: nextInstruction.routeData()}),
|
||||
provide(RouteParams, {asValue: new RouteParams(nextInstruction.params)}),
|
||||
provide(routerMod.Router, {asValue: childRouter})
|
||||
]);
|
||||
return this._loader.loadNextToLocation(componentType, this._elementRef, bindings)
|
||||
return this._loader.loadNextToLocation(componentType, this._elementRef, providers)
|
||||
.then((componentRef) => {
|
||||
this._componentRef = componentRef;
|
||||
if (hasLifecycleHook(hookMod.onActivate, componentType)) {
|
||||
|
Reference in New Issue
Block a user