refactor(core): separate reflective injector from Injector interface
BREAKING CHANGE: - Injector was renamed into `ReflectiveInjector`, as `Injector` is only an abstract class with one method on it - `Injector.getOptional()` was changed into `Injector.get(token, notFoundValue)` to make implementing injectors simpler - `ViewContainerRef.createComponent` now takes an `Injector` instead of `ResolvedProviders`. If a reflective injector should be used, create one before calling this method. (e.g. via `ReflectiveInjector.resolveAndCreate(…)`.
This commit is contained in:
@ -143,7 +143,8 @@ export class RedirectToParentCmp {
|
||||
@RouteConfig([new Route({path: '/', component: HelloCmp})])
|
||||
export class DynamicLoaderCmp {
|
||||
private _componentRef: ComponentRef = null;
|
||||
@ViewChild('viewport', {read: ViewContainerRef}) private _viewport: ViewContainerRef;
|
||||
|
||||
@ViewChild('viewport', {read: ViewContainerRef}) viewport: ViewContainerRef;
|
||||
|
||||
constructor(private _dynamicComponentLoader: DynamicComponentLoader) {}
|
||||
|
||||
@ -152,8 +153,7 @@ export class DynamicLoaderCmp {
|
||||
this._componentRef.destroy();
|
||||
this._componentRef = null;
|
||||
}
|
||||
return this._dynamicComponentLoader.loadNextToLocation(DynamicallyLoadedComponent,
|
||||
this._viewport)
|
||||
return this._dynamicComponentLoader.loadNextToLocation(DynamicallyLoadedComponent, viewport)
|
||||
.then((cmp) => { this._componentRef = cmp; });
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
SpyObject
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {Injector, provide} from 'angular2/core';
|
||||
import {Injector, provide, ReflectiveInjector} from 'angular2/core';
|
||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
|
||||
import {Location, LocationStrategy, APP_BASE_HREF} from 'angular2/platform/common';
|
||||
@ -26,7 +26,7 @@ export function main() {
|
||||
function makeLocation(baseHref: string = '/my/app', provider: any = CONST_EXPR([])): Location {
|
||||
locationStrategy = new MockLocationStrategy();
|
||||
locationStrategy.internalBaseHref = baseHref;
|
||||
let injector = Injector.resolveAndCreate(
|
||||
let injector = ReflectiveInjector.resolveAndCreate(
|
||||
[Location, provide(LocationStrategy, {useValue: locationStrategy}), provider]);
|
||||
return location = injector.get(Location);
|
||||
}
|
||||
|
Reference in New Issue
Block a user