diff --git a/modules/angular2/platform/browser.ts b/modules/angular2/platform/browser.ts
index 2f8ba0628f..f57b5069c6 100644
--- a/modules/angular2/platform/browser.ts
+++ b/modules/angular2/platform/browser.ts
@@ -121,7 +121,7 @@ export function browserPlatform(): PlatformRef {
*/
export function bootstrap(
appComponentType: Type,
- customProviders?: Array): Promise {
+ customProviders?: Array): Promise> {
reflector.reflectionCapabilities = new ReflectionCapabilities();
var appInjector = ReflectiveInjector.resolveAndCreate(
[BROWSER_APP_PROVIDERS, isPresent(customProviders) ? customProviders : []],
diff --git a/modules/angular2/platform/browser_static.ts b/modules/angular2/platform/browser_static.ts
index 2e062bdaa4..ff21424f73 100644
--- a/modules/angular2/platform/browser_static.ts
+++ b/modules/angular2/platform/browser_static.ts
@@ -47,7 +47,7 @@ export function browserStaticPlatform(): PlatformRef {
*/
export function bootstrapStatic(appComponentType: Type,
customProviders?: Array,
- initReflector?: Function): Promise {
+ initReflector?: Function): Promise> {
if (isPresent(initReflector)) {
initReflector();
}
diff --git a/modules/angular2/platform/worker_app.dart b/modules/angular2/platform/worker_app.dart
index 244331440d..a951be4bfb 100644
--- a/modules/angular2/platform/worker_app.dart
+++ b/modules/angular2/platform/worker_app.dart
@@ -39,7 +39,7 @@ PlatformRef workerAppPlatform(SendPort renderSendPort) {
return platform;
}
-Future bootstrapApp(
+Future> bootstrapApp(
SendPort renderSendPort,
Type appComponentType,
[List customProviders]) {
diff --git a/modules/angular2/platform/worker_app.ts b/modules/angular2/platform/worker_app.ts
index 4f3304ffbf..cd7033dbe7 100644
--- a/modules/angular2/platform/worker_app.ts
+++ b/modules/angular2/platform/worker_app.ts
@@ -44,7 +44,7 @@ export function workerAppPlatform(): PlatformRef {
export function bootstrapApp(
appComponentType: Type,
- customProviders?: Array): Promise {
+ customProviders?: Array): Promise> {
var appInjector = ReflectiveInjector.resolveAndCreate(
[WORKER_APP_APPLICATION, isPresent(customProviders) ? customProviders : []],
workerAppPlatform().injector);
diff --git a/modules/angular2/src/alt_router/directives/router_outlet.ts b/modules/angular2/src/alt_router/directives/router_outlet.ts
index 5e7b5dc5a7..be1fefb4b4 100644
--- a/modules/angular2/src/alt_router/directives/router_outlet.ts
+++ b/modules/angular2/src/alt_router/directives/router_outlet.ts
@@ -15,7 +15,7 @@ import {isPresent, isBlank} from 'angular2/src/facade/lang';
@Directive({selector: 'router-outlet'})
export class RouterOutlet {
- private _loaded: ComponentRef;
+ private _loaded: ComponentRef;
public outletMap: RouterOutletMap;
constructor(parentOutletMap: RouterOutletMap, private _location: ViewContainerRef,
@@ -32,8 +32,8 @@ export class RouterOutlet {
get isLoaded(): boolean { return isPresent(this._loaded); }
- load(factory: ComponentFactory, providers: ResolvedReflectiveProvider[],
- outletMap: RouterOutletMap): ComponentRef {
+ load(factory: ComponentFactory, providers: ResolvedReflectiveProvider[],
+ outletMap: RouterOutletMap): ComponentRef {
this.outletMap = outletMap;
let inj = ReflectiveInjector.fromResolvedProviders(providers, this._location.parentInjector);
this._loaded = this._location.createComponent(factory, this._location.length, inj, []);
diff --git a/modules/angular2/src/alt_router/segments.ts b/modules/angular2/src/alt_router/segments.ts
index 53d3cefa74..2c9e635b34 100644
--- a/modules/angular2/src/alt_router/segments.ts
+++ b/modules/angular2/src/alt_router/segments.ts
@@ -86,10 +86,10 @@ export class RouteSegment {
_type: Type;
/** @internal */
- _componentFactory: ComponentFactory;
+ _componentFactory: ComponentFactory;
constructor(public urlSegments: UrlSegment[], public parameters: {[key: string]: string},
- public outlet: string, type: Type, componentFactory: ComponentFactory) {
+ public outlet: string, type: Type, componentFactory: ComponentFactory) {
this._type = type;
this._componentFactory = componentFactory;
}
@@ -123,6 +123,6 @@ export function equalSegments(a: RouteSegment, b: RouteSegment): boolean {
return StringMapWrapper.equals(a.parameters, b.parameters);
}
-export function routeSegmentComponentFactory(a: RouteSegment): ComponentFactory {
+export function routeSegmentComponentFactory(a: RouteSegment): ComponentFactory {
return a._componentFactory;
}
\ No newline at end of file
diff --git a/modules/angular2/src/compiler/offline_compiler.ts b/modules/angular2/src/compiler/offline_compiler.ts
index 482209e7e7..f5d3962064 100644
--- a/modules/angular2/src/compiler/offline_compiler.ts
+++ b/modules/angular2/src/compiler/offline_compiler.ts
@@ -61,17 +61,18 @@ export class OfflineCompiler {
var hostMeta = createHostComponentMeta(compMeta.type, compMeta.selector);
var hostViewFactoryVar = this._compileComponent(hostMeta, [compMeta], [], statements);
var compFactoryVar = `${compMeta.type.name}NgFactory`;
- statements.push(o.variable(compFactoryVar)
- .set(o.importExpr(_COMPONENT_FACTORY_IDENTIFIER)
- .instantiate(
- [
- o.literal(compMeta.selector),
- o.variable(hostViewFactoryVar),
- o.importExpr(compMeta.type)
- ],
- o.importType(_COMPONENT_FACTORY_IDENTIFIER, null,
- [o.TypeModifier.Const])))
- .toDeclStmt(null, [o.StmtModifier.Final]));
+ statements.push(
+ o.variable(compFactoryVar)
+ .set(o.importExpr(_COMPONENT_FACTORY_IDENTIFIER, [o.importType(compMeta.type)])
+ .instantiate(
+ [
+ o.literal(compMeta.selector),
+ o.variable(hostViewFactoryVar),
+ o.importExpr(compMeta.type)
+ ],
+ o.importType(_COMPONENT_FACTORY_IDENTIFIER,
+ [o.importType(compMeta.type)], [o.TypeModifier.Const])))
+ .toDeclStmt(null, [o.StmtModifier.Final]));
exportedVars.push(compFactoryVar);
});
return this._codegenSourceModule(moduleUrl, statements, exportedVars);
diff --git a/modules/angular2/src/compiler/runtime_compiler.ts b/modules/angular2/src/compiler/runtime_compiler.ts
index 5d802fa2a7..b4a38a34d0 100644
--- a/modules/angular2/src/compiler/runtime_compiler.ts
+++ b/modules/angular2/src/compiler/runtime_compiler.ts
@@ -77,7 +77,7 @@ export class RuntimeCompiler implements ComponentResolver {
private _viewCompiler: ViewCompiler, private _xhr: XHR,
private _genConfig: CompilerConfig) {}
- resolveComponent(componentType: Type): Promise {
+ resolveComponent(componentType: Type): Promise> {
var compMeta: CompileDirectiveMetadata =
this._metadataResolver.getDirectiveMetadata(componentType);
var hostCacheKey = this._hostCacheKeys.get(componentType);
diff --git a/modules/angular2/src/core/application_ref.ts b/modules/angular2/src/core/application_ref.ts
index e37090576a..f5467a403d 100644
--- a/modules/angular2/src/core/application_ref.ts
+++ b/modules/angular2/src/core/application_ref.ts
@@ -94,8 +94,8 @@ export function getPlatform(): PlatformRef {
* Shortcut for ApplicationRef.bootstrap.
* Requires a platform the be created first.
*/
-export function coreBootstrap(injector: Injector,
- componentFactory: ComponentFactory): ComponentRef {
+export function coreBootstrap(injector: Injector,
+ componentFactory: ComponentFactory): ComponentRef {
var appRef: ApplicationRef = injector.get(ApplicationRef);
return appRef.bootstrap(componentFactory);
}
@@ -106,7 +106,7 @@ export function coreBootstrap(injector: Injector,
* Requires a platform the be created first.
*/
export function coreLoadAndBootstrap(injector: Injector,
- componentType: Type): Promise {
+ componentType: Type): Promise> {
var appRef: ApplicationRef = injector.get(ApplicationRef);
return appRef.run(() => {
var componentResolver: ComponentResolver = injector.get(ComponentResolver);
@@ -190,7 +190,7 @@ export abstract class ApplicationRef {
* Register a listener to be called each time `bootstrap()` is called to bootstrap
* a new root component.
*/
- abstract registerBootstrapListener(listener: (ref: ComponentRef) => void): void;
+ abstract registerBootstrapListener(listener: (ref: ComponentRef) => void): void;
/**
* Register a listener to be called when the application is disposed.
@@ -221,7 +221,7 @@ export abstract class ApplicationRef {
* ### Example
* {@example core/ts/platform/platform.ts region='longform'}
*/
- abstract bootstrap(componentFactory: ComponentFactory): ComponentRef;
+ abstract bootstrap(componentFactory: ComponentFactory): ComponentRef;
/**
* Retrieve the application {@link Injector}.
@@ -266,7 +266,7 @@ export class ApplicationRef_ extends ApplicationRef {
/** @internal */
private _disposeListeners: Function[] = [];
/** @internal */
- private _rootComponents: ComponentRef[] = [];
+ private _rootComponents: ComponentRef[] = [];
/** @internal */
private _rootComponentTypes: Type[] = [];
/** @internal */
@@ -315,7 +315,7 @@ export class ApplicationRef_ extends ApplicationRef {
(_) => { this._zone.run(() => { this.tick(); }); });
}
- registerBootstrapListener(listener: (ref: ComponentRef) => void): void {
+ registerBootstrapListener(listener: (ref: ComponentRef) => void): void {
this._bootstrapListeners.push(listener);
}
@@ -357,7 +357,7 @@ export class ApplicationRef_ extends ApplicationRef {
return isPromise(result) ? completer.promise : result;
}
- bootstrap(componentFactory: ComponentFactory): ComponentRef {
+ bootstrap(componentFactory: ComponentFactory): ComponentRef {
if (!this._asyncInitDone) {
throw new BaseException(
'Cannot bootstrap as there are still asynchronous initializers running. Wait for them using waitForAsyncInitializers().');
@@ -383,7 +383,7 @@ export class ApplicationRef_ extends ApplicationRef {
}
/** @internal */
- _loadComponent(componentRef: ComponentRef): void {
+ _loadComponent(componentRef: ComponentRef): void {
this._changeDetectorRefs.push(componentRef.changeDetectorRef);
this.tick();
this._rootComponents.push(componentRef);
@@ -391,7 +391,7 @@ export class ApplicationRef_ extends ApplicationRef {
}
/** @internal */
- _unloadComponent(componentRef: ComponentRef): void {
+ _unloadComponent(componentRef: ComponentRef): void {
if (!ListWrapper.contains(this._rootComponents, componentRef)) {
return;
}
diff --git a/modules/angular2/src/core/linker/component_factory.ts b/modules/angular2/src/core/linker/component_factory.ts
index de77653b49..7ca5e5f3a8 100644
--- a/modules/angular2/src/core/linker/component_factory.ts
+++ b/modules/angular2/src/core/linker/component_factory.ts
@@ -14,7 +14,7 @@ import {ChangeDetectorRef} from '../change_detection/change_detection';
* Component Instance and allows you to destroy the Component Instance via the {@link #destroy}
* method.
*/
-export abstract class ComponentRef {
+export abstract class ComponentRef {
/**
* Location of the Host Element of this Component Instance.
*/
@@ -28,7 +28,7 @@ export abstract class ComponentRef {
/**
* The instance of the Component.
*/
- get instance(): any { return unimplemented(); };
+ get instance(): C { return unimplemented(); };
/**
* The {@link ViewRef} of the Host View of this Component instance.
@@ -56,11 +56,11 @@ export abstract class ComponentRef {
abstract onDestroy(callback: Function): void;
}
-export class ComponentRef_ extends ComponentRef {
+export class ComponentRef_ extends ComponentRef {
constructor(private _hostElement: AppElement, private _componentType: Type) { super(); }
get location(): ElementRef { return this._hostElement.elementRef; }
get injector(): Injector { return this._hostElement.injector; }
- get instance(): any { return this._hostElement.component; };
+ get instance(): C { return this._hostElement.component; };
get hostView(): ViewRef { return this._hostElement.parentView.ref; };
get changeDetectorRef(): ChangeDetectorRef { return this._hostElement.parentView.ref; };
get componentType(): Type { return this._componentType; }
@@ -72,7 +72,7 @@ export class ComponentRef_ extends ComponentRef {
const EMPTY_CONTEXT = /*@ts2dart_const*/ new Object();
/*@ts2dart_const*/
-export class ComponentFactory {
+export class ComponentFactory {
constructor(public selector: string, private _viewFactory: Function,
private _componentType: Type) {}
@@ -82,7 +82,7 @@ export class ComponentFactory {
* Creates a new component.
*/
create(injector: Injector, projectableNodes: any[][] = null,
- rootSelectorOrNode: string | any = null): ComponentRef {
+ rootSelectorOrNode: string | any = null): ComponentRef {
var vu: ViewUtils = injector.get(ViewUtils);
if (isBlank(projectableNodes)) {
projectableNodes = [];
@@ -90,6 +90,6 @@ export class ComponentFactory {
// Note: Host views don't need a declarationAppElement!
var hostView = this._viewFactory(vu, injector, null);
var hostElement = hostView.create(EMPTY_CONTEXT, projectableNodes, rootSelectorOrNode);
- return new ComponentRef_(hostElement, this._componentType);
+ return new ComponentRef_(hostElement, this._componentType);
}
}
diff --git a/modules/angular2/src/core/linker/component_resolver.ts b/modules/angular2/src/core/linker/component_resolver.ts
index f7f536756d..676ab093c0 100644
--- a/modules/angular2/src/core/linker/component_resolver.ts
+++ b/modules/angular2/src/core/linker/component_resolver.ts
@@ -10,7 +10,7 @@ import {ComponentFactory} from './component_factory';
* can later be used to create and render a Component instance.
*/
export abstract class ComponentResolver {
- abstract resolveComponent(componentType: Type): Promise;
+ abstract resolveComponent(componentType: Type): Promise>;
abstract clearCache();
}
@@ -20,7 +20,7 @@ function _isComponentFactory(type: any): boolean {
@Injectable()
export class ReflectorComponentResolver extends ComponentResolver {
- resolveComponent(componentType: Type): Promise {
+ resolveComponent(componentType: Type): Promise> {
var metadatas = reflector.annotations(componentType);
var componentFactory = metadatas.find(_isComponentFactory);
diff --git a/modules/angular2/src/core/linker/dynamic_component_loader.ts b/modules/angular2/src/core/linker/dynamic_component_loader.ts
index 5aa890645d..d8bacca173 100644
--- a/modules/angular2/src/core/linker/dynamic_component_loader.ts
+++ b/modules/angular2/src/core/linker/dynamic_component_loader.ts
@@ -65,7 +65,8 @@ export abstract class DynamicComponentLoader {
* ```
*/
abstract loadAsRoot(type: Type, overrideSelectorOrNode: string | any, injector: Injector,
- onDispose?: () => void, projectableNodes?: any[][]): Promise;
+ onDispose?: () => void,
+ projectableNodes?: any[][]): Promise>;
/**
@@ -110,7 +111,7 @@ export abstract class DynamicComponentLoader {
*/
abstract loadNextToLocation(type: Type, location: ViewContainerRef,
providers?: ResolvedReflectiveProvider[],
- projectableNodes?: any[][]): Promise;
+ projectableNodes?: any[][]): Promise>;
}
@Injectable()
@@ -118,7 +119,7 @@ export class DynamicComponentLoader_ extends DynamicComponentLoader {
constructor(private _compiler: ComponentResolver) { super(); }
loadAsRoot(type: Type, overrideSelectorOrNode: string | any, injector: Injector,
- onDispose?: () => void, projectableNodes?: any[][]): Promise {
+ onDispose?: () => void, projectableNodes?: any[][]): Promise> {
return this._compiler.resolveComponent(type).then(componentFactory => {
var componentRef = componentFactory.create(
injector, projectableNodes,
@@ -132,7 +133,7 @@ export class DynamicComponentLoader_ extends DynamicComponentLoader {
loadNextToLocation(type: Type, location: ViewContainerRef,
providers: ResolvedReflectiveProvider[] = null,
- projectableNodes: any[][] = null): Promise {
+ projectableNodes: any[][] = null): Promise> {
return this._compiler.resolveComponent(type).then(componentFactory => {
var contextInjector = location.parentInjector;
var childInjector = isPresent(providers) && providers.length > 0 ?
diff --git a/modules/angular2/src/core/linker/view_container_ref.ts b/modules/angular2/src/core/linker/view_container_ref.ts
index dcac8e1852..85b404e9ee 100644
--- a/modules/angular2/src/core/linker/view_container_ref.ts
+++ b/modules/angular2/src/core/linker/view_container_ref.ts
@@ -62,9 +62,8 @@ export abstract class ViewContainerRef {
*
* Returns the {@link ViewRef} for the newly created View.
*/
- // TODO(tbosch): Use a generic once ts2dart supports it.
- abstract createEmbeddedView(templateRef: TemplateRef, context?: any,
- index?: number): EmbeddedViewRef;
+ abstract createEmbeddedView(templateRef: TemplateRef, context?: C,
+ index?: number): EmbeddedViewRef;
/**
* Instantiates a single {@link Component} and inserts its Host View into this container at the
@@ -79,8 +78,8 @@ export abstract class ViewContainerRef {
*
* Returns the {@link ComponentRef} of the Host View created for the newly instantiated Component.
*/
- abstract createComponent(componentFactory: ComponentFactory, index?: number, injector?: Injector,
- projectableNodes?: any[][]): ComponentRef;
+ abstract createComponent(componentFactory: ComponentFactory, index?: number,
+ injector?: Injector, projectableNodes?: any[][]): ComponentRef;
/**
* Inserts a View identified by a {@link ViewRef} into the container at the specified `index`.
@@ -129,9 +128,8 @@ export class ViewContainerRef_ implements ViewContainerRef {
// TODO(rado): profile and decide whether bounds checks should be added
// to the methods below.
- // TODO(tbosch): use a generic C once ts2dart supports it.
- createEmbeddedView(templateRef: TemplateRef, context: any = null,
- index: number = -1): EmbeddedViewRef {
+ createEmbeddedView(templateRef: TemplateRef, context: C = null,
+ index: number = -1): EmbeddedViewRef {
var viewRef: EmbeddedViewRef = templateRef.createEmbeddedView(context);
this.insert(viewRef, index);
return viewRef;
@@ -141,8 +139,8 @@ export class ViewContainerRef_ implements ViewContainerRef {
_createComponentInContainerScope: WtfScopeFn =
wtfCreateScope('ViewContainerRef#createComponent()');
- createComponent(componentFactory: ComponentFactory, index: number = -1, injector: Injector = null,
- projectableNodes: any[][] = null): ComponentRef {
+ createComponent(componentFactory: ComponentFactory, index: number = -1,
+ injector: Injector = null, projectableNodes: any[][] = null): ComponentRef {
var s = this._createComponentInContainerScope();
var contextInjector = isPresent(injector) ? injector : this._element.parentInjector;
var componentRef = componentFactory.create(contextInjector, projectableNodes);
diff --git a/modules/angular2/src/mock/mock_application_ref.ts b/modules/angular2/src/mock/mock_application_ref.ts
index 77bf0182b3..5cfcab5447 100644
--- a/modules/angular2/src/mock/mock_application_ref.ts
+++ b/modules/angular2/src/mock/mock_application_ref.ts
@@ -9,11 +9,11 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone';
*/
@Injectable()
export class MockApplicationRef extends ApplicationRef {
- registerBootstrapListener(listener: (ref: ComponentRef) => void): void {}
+ registerBootstrapListener(listener: (ref: ComponentRef) => void): void {}
registerDisposeListener(dispose: () => void): void {}
- bootstrap(componentFactory: ComponentFactory): ComponentRef { return null; }
+ bootstrap(componentFactory: ComponentFactory): ComponentRef { return null; }
get injector(): Injector { return null; };
diff --git a/modules/angular2/src/platform/browser/tools/common_tools.ts b/modules/angular2/src/platform/browser/tools/common_tools.ts
index 4eeb55da32..d39510cd19 100644
--- a/modules/angular2/src/platform/browser/tools/common_tools.ts
+++ b/modules/angular2/src/platform/browser/tools/common_tools.ts
@@ -15,7 +15,7 @@ export class ChangeDetectionPerfRecord {
export class AngularTools {
profiler: AngularProfiler;
- constructor(ref: ComponentRef) { this.profiler = new AngularProfiler(ref); }
+ constructor(ref: ComponentRef) { this.profiler = new AngularProfiler(ref); }
}
/**
@@ -25,7 +25,7 @@ export class AngularTools {
export class AngularProfiler {
appRef: ApplicationRef;
- constructor(ref: ComponentRef) { this.appRef = ref.injector.get(ApplicationRef); }
+ constructor(ref: ComponentRef) { this.appRef = ref.injector.get(ApplicationRef); }
/**
* Exercises change detection in a loop and then prints the average amount of
diff --git a/modules/angular2/src/platform/browser/tools/tools.dart b/modules/angular2/src/platform/browser/tools/tools.dart
index 8b65787009..fab97a3201 100644
--- a/modules/angular2/src/platform/browser/tools/tools.dart
+++ b/modules/angular2/src/platform/browser/tools/tools.dart
@@ -16,7 +16,7 @@ import 'common_tools.dart' show AngularTools;
* 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
* then hit Enter.
*/
-void enableDebugTools(ComponentRef ref) {
+void enableDebugTools(ComponentRef ref) {
final tools = new AngularTools(ref);
context['ng'] = new JsObject.jsify({
'profiler': {
diff --git a/modules/angular2/src/platform/browser/tools/tools.ts b/modules/angular2/src/platform/browser/tools/tools.ts
index 75ebeabefa..352b65bbc2 100644
--- a/modules/angular2/src/platform/browser/tools/tools.ts
+++ b/modules/angular2/src/platform/browser/tools/tools.ts
@@ -15,7 +15,7 @@ var context = global;
* 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
* then hit Enter.
*/
-export function enableDebugTools(ref: ComponentRef): void {
+export function enableDebugTools(ref: ComponentRef): void {
context.ng = new AngularTools(ref);
}
diff --git a/modules/angular2/src/router/directives/router_outlet.ts b/modules/angular2/src/router/directives/router_outlet.ts
index d60e5883e7..58296e0ef2 100644
--- a/modules/angular2/src/router/directives/router_outlet.ts
+++ b/modules/angular2/src/router/directives/router_outlet.ts
@@ -34,7 +34,7 @@ let _resolveToTrue = PromiseWrapper.resolve(true);
@Directive({selector: 'router-outlet'})
export class RouterOutlet implements OnDestroy {
name: string = null;
- private _componentRef: Promise = null;
+ private _componentRef: Promise> = null;
private _currentInstruction: ComponentInstruction = null;
@Output('activate') public activateEvents = new EventEmitter();
@@ -70,7 +70,7 @@ export class RouterOutlet implements OnDestroy {
this.activateEvents.emit(componentRef.instance);
if (hasLifecycleHook(hookMod.routerOnActivate, componentType)) {
return this._componentRef.then(
- (ref: ComponentRef) =>
+ (ref: ComponentRef) =>
(ref.instance).routerOnActivate(nextInstruction, previousInstruction));
} else {
return componentRef;
@@ -96,7 +96,7 @@ export class RouterOutlet implements OnDestroy {
return PromiseWrapper.resolve(
hasLifecycleHook(hookMod.routerOnReuse, this._currentInstruction.componentType) ?
this._componentRef.then(
- (ref: ComponentRef) =>
+ (ref: ComponentRef) =>
(ref.instance).routerOnReuse(nextInstruction, previousInstruction)) :
true);
}
@@ -111,13 +111,13 @@ export class RouterOutlet implements OnDestroy {
if (isPresent(this._componentRef) && isPresent(this._currentInstruction) &&
hasLifecycleHook(hookMod.routerOnDeactivate, this._currentInstruction.componentType)) {
next = this._componentRef.then(
- (ref: ComponentRef) =>
+ (ref: ComponentRef) =>
(ref.instance)
.routerOnDeactivate(nextInstruction, this._currentInstruction));
}
return next.then((_) => {
if (isPresent(this._componentRef)) {
- var onDispose = this._componentRef.then((ref: ComponentRef) => ref.destroy());
+ var onDispose = this._componentRef.then((ref: ComponentRef) => ref.destroy());
this._componentRef = null;
return onDispose;
}
@@ -138,7 +138,7 @@ export class RouterOutlet implements OnDestroy {
}
if (hasLifecycleHook(hookMod.routerCanDeactivate, this._currentInstruction.componentType)) {
return this._componentRef.then(
- (ref: ComponentRef) =>
+ (ref: ComponentRef) =>
(ref.instance)
.routerCanDeactivate(nextInstruction, this._currentInstruction));
} else {
@@ -164,7 +164,7 @@ export class RouterOutlet implements OnDestroy {
result = false;
} else if (hasLifecycleHook(hookMod.routerCanReuse, this._currentInstruction.componentType)) {
result = this._componentRef.then(
- (ref: ComponentRef) =>
+ (ref: ComponentRef) =>
(ref.instance).routerCanReuse(nextInstruction, this._currentInstruction));
} else {
result = nextInstruction == this._currentInstruction ||
diff --git a/modules/angular2/src/testing/test_component_builder.ts b/modules/angular2/src/testing/test_component_builder.ts
index e877aa98f7..ba0665b8e2 100644
--- a/modules/angular2/src/testing/test_component_builder.ts
+++ b/modules/angular2/src/testing/test_component_builder.ts
@@ -1,7 +1,8 @@
import {
OpaqueToken,
ComponentRef,
- DynamicComponentLoader,
+ ComponentFactory,
+ ComponentResolver,
Injector,
Injectable,
ViewMetadata,
@@ -34,7 +35,7 @@ export var ComponentFixtureNoNgZone = new OpaqueToken("ComponentFixtureNoNgZone"
/**
* Fixture for debugging and testing a component.
*/
-export class ComponentFixture {
+export class ComponentFixture {
/**
* The DebugElement associated with the root element of this component.
*/
@@ -58,7 +59,7 @@ export class ComponentFixture {
/**
* The ComponentRef for the component
*/
- componentRef: ComponentRef;
+ componentRef: ComponentRef;
/**
* The ChangeDetectorRef for the component
@@ -79,7 +80,7 @@ export class ComponentFixture {
private _onMicrotaskEmptySubscription = null;
private _onErrorSubscription = null;
- constructor(componentRef: ComponentRef, ngZone: NgZone, autoDetect: boolean) {
+ constructor(componentRef: ComponentRef, ngZone: NgZone, autoDetect: boolean) {
this.changeDetectorRef = componentRef.changeDetectorRef;
this.elementRef = componentRef.location;
this.debugElement = getDebugNode(this.elementRef.nativeElement);
@@ -334,15 +335,30 @@ export class TestComponentBuilder {
return this.overrideViewProviders(type, providers);
}
+ private _create(ngZone: NgZone, componentFactory: ComponentFactory): ComponentFixture {
+ let rootElId = `root${_nextRootElementId++}`;
+ let rootEl = el(``);
+ let doc = this._injector.get(DOCUMENT);
+
+ // TODO(juliemr): can/should this be optional?
+ let oldRoots = DOM.querySelectorAll(doc, '[id^=root]');
+ for (let i = 0; i < oldRoots.length; i++) {
+ DOM.remove(oldRoots[i]);
+ }
+ DOM.appendChild(doc.body, rootEl);
+ var componentRef = componentFactory.create(this._injector, [], `#${rootElId}`);
+ let autoDetect: boolean = this._injector.get(ComponentFixtureAutoDetect, false);
+ return new ComponentFixture(componentRef, ngZone, autoDetect);
+ }
+
/**
* Builds and returns a ComponentFixture.
*
* @return {Promise}
*/
- createAsync(rootComponentType: Type): Promise {
+ createAsync(rootComponentType: Type): Promise> {
let noNgZone = IS_DART || this._injector.get(ComponentFixtureNoNgZone, false);
let ngZone: NgZone = noNgZone ? null : this._injector.get(NgZone, null);
- let autoDetect: boolean = this._injector.get(ComponentFixtureAutoDetect, false);
let initComponent = () => {
let mockDirectiveResolver = this._injector.get(DirectiveResolver);
@@ -359,28 +375,15 @@ export class TestComponentBuilder {
this._viewBindingsOverrides.forEach(
(bindings, type) => mockDirectiveResolver.setViewBindingsOverride(type, bindings));
- let rootElId = `root${_nextRootElementId++}`;
- let rootEl = el(``);
- let doc = this._injector.get(DOCUMENT);
-
- // TODO(juliemr): can/should this be optional?
- let oldRoots = DOM.querySelectorAll(doc, '[id^=root]');
- for (let i = 0; i < oldRoots.length; i++) {
- DOM.remove(oldRoots[i]);
- }
- DOM.appendChild(doc.body, rootEl);
-
- let promise: Promise =
- this._injector.get(DynamicComponentLoader)
- .loadAsRoot(rootComponentType, `#${rootElId}`, this._injector);
- return promise.then(
- (componentRef) => { return new ComponentFixture(componentRef, ngZone, autoDetect); });
+ let promise: Promise> =
+ this._injector.get(ComponentResolver).resolveComponent(rootComponentType);
+ return promise.then(componentFactory => this._create(ngZone, componentFactory));
};
return ngZone == null ? initComponent() : ngZone.run(initComponent);
}
- createFakeAsync(rootComponentType: Type): ComponentFixture {
+ createFakeAsync(rootComponentType: Type): ComponentFixture {
let result;
let error;
PromiseWrapper.then(this.createAsync(rootComponentType), (_result) => { result = _result; },
@@ -391,4 +394,12 @@ export class TestComponentBuilder {
}
return result;
}
+
+ createSync(componentFactory: ComponentFactory): ComponentFixture {
+ let noNgZone = IS_DART || this._injector.get(ComponentFixtureNoNgZone, false);
+ let ngZone: NgZone = noNgZone ? null : this._injector.get(NgZone, null);
+
+ let initComponent = () => this._create(ngZone, componentFactory);
+ return ngZone == null ? initComponent() : ngZone.run(initComponent);
+ }
}
diff --git a/modules/angular2/src/upgrade/downgrade_ng2_adapter.ts b/modules/angular2/src/upgrade/downgrade_ng2_adapter.ts
index 89b254c7cf..74859d7a72 100644
--- a/modules/angular2/src/upgrade/downgrade_ng2_adapter.ts
+++ b/modules/angular2/src/upgrade/downgrade_ng2_adapter.ts
@@ -21,7 +21,7 @@ export class DowngradeNg2ComponentAdapter {
component: any = null;
inputChangeCount: number = 0;
inputChanges: {[key: string]: SimpleChange} = null;
- componentRef: ComponentRef = null;
+ componentRef: ComponentRef = null;
changeDetector: ChangeDetectorRef = null;
componentScope: angular.IScope;
childNodes: Node[];
@@ -30,7 +30,8 @@ export class DowngradeNg2ComponentAdapter {
constructor(private id: string, private info: ComponentInfo,
private element: angular.IAugmentedJQuery, private attrs: angular.IAttributes,
private scope: angular.IScope, private parentInjector: Injector,
- private parse: angular.IParseService, private componentFactory: ComponentFactory) {
+ private parse: angular.IParseService,
+ private componentFactory: ComponentFactory) {
(this.element[0]).id = id;
this.componentScope = scope.$new();
this.childNodes = element.contents();
diff --git a/modules/angular2/src/upgrade/upgrade_adapter.ts b/modules/angular2/src/upgrade/upgrade_adapter.ts
index aba3ebdac7..f6aa8fc8ac 100644
--- a/modules/angular2/src/upgrade/upgrade_adapter.ts
+++ b/modules/angular2/src/upgrade/upgrade_adapter.ts
@@ -524,12 +524,12 @@ export class UpgradeAdapter {
private compileNg2Components(compiler: ComponentResolver,
componentFactoryRefMap: ComponentFactoryRefMap):
Promise {
- var promises: Array> = [];
+ var promises: Array>> = [];
var types = this.upgradedComponents;
for (var i = 0; i < types.length; i++) {
promises.push(compiler.resolveComponent(types[i]));
}
- return Promise.all(promises).then((componentFactories: Array) => {
+ return Promise.all(promises).then((componentFactories: Array>) => {
var types = this.upgradedComponents;
for (var i = 0; i < componentFactories.length; i++) {
componentFactoryRefMap[getComponentInfo(types[i]).selector] = componentFactories[i];
@@ -540,14 +540,14 @@ export class UpgradeAdapter {
}
interface ComponentFactoryRefMap {
- [selector: string]: ComponentFactory;
+ [selector: string]: ComponentFactory;
}
function ng1ComponentDirective(info: ComponentInfo, idPrefix: string): Function {
(directiveFactory).$inject = [NG2_COMPONENT_FACTORY_REF_MAP, NG1_PARSE];
function directiveFactory(componentFactoryRefMap: ComponentFactoryRefMap,
parse: angular.IParseService): angular.IDirective {
- var componentFactory: ComponentFactory = componentFactoryRefMap[info.selector];
+ var componentFactory: ComponentFactory = componentFactoryRefMap[info.selector];
if (!componentFactory) throw new Error('Expecting ComponentFactory for: ' + info.selector);
var idCount = 0;
return {
diff --git a/modules/angular2/test/alt_router/integration_spec.ts b/modules/angular2/test/alt_router/integration_spec.ts
index 7e90d73986..ec7fa1181e 100644
--- a/modules/angular2/test/alt_router/integration_spec.ts
+++ b/modules/angular2/test/alt_router/integration_spec.ts
@@ -213,12 +213,12 @@ export function main() {
});
}
-function advance(fixture: ComponentFixture): void {
+function advance(fixture: ComponentFixture): void {
tick();
fixture.detectChanges();
}
-function compileRoot(tcb: TestComponentBuilder): Promise {
+function compileRoot(tcb: TestComponentBuilder): Promise> {
return tcb.createAsync(RootCmp);
}
diff --git a/modules/angular2/test/common/directives/ng_class_spec.ts b/modules/angular2/test/common/directives/ng_class_spec.ts
index 90c44321e1..d112bc8199 100644
--- a/modules/angular2/test/common/directives/ng_class_spec.ts
+++ b/modules/angular2/test/common/directives/ng_class_spec.ts
@@ -19,7 +19,7 @@ import {Component, provide} from 'angular2/core';
import {NgFor} from 'angular2/common';
import {NgClass} from 'angular2/src/common/directives/ng_class';
-function detectChangesAndCheck(fixture: ComponentFixture, classes: string) {
+function detectChangesAndCheck(fixture: ComponentFixture, classes: string) {
fixture.detectChanges();
expect(fixture.debugElement.children[0].nativeElement.className).toEqual(classes);
}
diff --git a/modules/angular2/test/common/forms/integration_spec.ts b/modules/angular2/test/common/forms/integration_spec.ts
index 73a719e8c1..08f082f1bf 100644
--- a/modules/angular2/test/common/forms/integration_spec.ts
+++ b/modules/angular2/test/common/forms/integration_spec.ts
@@ -132,9 +132,7 @@ export function main() {
{{name}}
`;
- var fixture: ComponentFixture;
-
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.form = new ControlGroup({});
@@ -928,8 +926,7 @@ export function main() {
var t =
``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = 'oldValue';
@@ -952,8 +949,7 @@ export function main() {
var t = ``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.form = form;
fixture.debugElement.componentInstance.name = "oldValue";
@@ -978,8 +974,7 @@ export function main() {
`;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = null;
fixture.detectChanges();
@@ -997,8 +992,7 @@ export function main() {
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
var t = ``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = 'old';
var form = fixture.debugElement.query(By.css("form"));
@@ -1031,8 +1025,7 @@ export function main() {
`;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = 'show';
fixture.detectChanges();
@@ -1058,8 +1051,7 @@ export function main() {
`;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = 'show';
fixture.detectChanges();
@@ -1081,8 +1073,7 @@ export function main() {
`;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = "oldValue";
fixture.detectChanges();
@@ -1103,8 +1094,7 @@ export function main() {
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
var t = ``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = "oldValue";
fixture.detectChanges();
@@ -1131,8 +1121,7 @@ export function main() {
`;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((f) => { fixture = f; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.data = {
@@ -1248,8 +1237,7 @@ export function main() {
var form = new Control("");
var t = ``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.form = form;
fixture.detectChanges();
@@ -1276,8 +1264,7 @@ export function main() {
it("should update the view when the model is set back to what used to be in the view",
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
var t = ``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.debugElement.componentInstance.name = "";
fixture.detectChanges();
@@ -1311,8 +1298,7 @@ export function main() {
// fixed.
var t = ``;
- var fixture: ComponentFixture;
- tcb.overrideTemplate(MyComp, t).createAsync(MyComp).then((root) => { fixture = root; });
+ let fixture = tcb.overrideTemplate(MyComp, t).createFakeAsync(MyComp);
tick();
fixture.detectChanges();
})));
diff --git a/modules/angular2/test/compiler/offline_compiler_codegen_typed.ts b/modules/angular2/test/compiler/offline_compiler_codegen_typed.ts
index c3edce06aa..b263461f35 100644
--- a/modules/angular2/test/compiler/offline_compiler_codegen_typed.ts
+++ b/modules/angular2/test/compiler/offline_compiler_codegen_typed.ts
@@ -4,8 +4,9 @@ import {TypeScriptEmitter} from 'angular2/src/compiler/output/ts_emitter';
import {DartEmitter} from 'angular2/src/compiler/output/dart_emitter';
import {compileComp, compAMetadata} from './offline_compiler_util';
import {ComponentFactory} from 'angular2/src/core/linker/component_factory';
+import {CompA} from './offline_compiler_util';
-export const CompANgFactory: ComponentFactory = null;
+export const CompANgFactory: ComponentFactory = null;
// Generator
export function main(args: string[]) {
diff --git a/modules/angular2/test/compiler/offline_compiler_codegen_untyped.ts b/modules/angular2/test/compiler/offline_compiler_codegen_untyped.ts
index 2ca4eefc20..636a88bd95 100644
--- a/modules/angular2/test/compiler/offline_compiler_codegen_untyped.ts
+++ b/modules/angular2/test/compiler/offline_compiler_codegen_untyped.ts
@@ -3,8 +3,9 @@ import {print} from 'angular2/src/facade/lang';
import {JavaScriptEmitter} from 'angular2/src/compiler/output/js_emitter';
import {compileComp, compAMetadata} from './offline_compiler_util';
import {ComponentFactory} from 'angular2/src/core/linker/component_factory';
+import {CompA} from './offline_compiler_util';
-export const CompANgFactory: ComponentFactory = null;
+export const CompANgFactory: ComponentFactory = null;
// Generator
export function main(args: string[]) {
diff --git a/modules/angular2/test/compiler/offline_compiler_spec.ts b/modules/angular2/test/compiler/offline_compiler_spec.ts
index 5c5d525479..adfc966863 100644
--- a/modules/angular2/test/compiler/offline_compiler_spec.ts
+++ b/modules/angular2/test/compiler/offline_compiler_spec.ts
@@ -16,7 +16,6 @@ import {
import {IS_DART} from 'angular2/src/facade/lang';
import {Injector} from 'angular2/core';
-import {DebugNode, DebugElement, getDebugNode} from 'angular2/src/core/debug/debug_node';
import {ComponentFactory} from 'angular2/src/core/linker/component_factory';
import * as typed from './offline_compiler_codegen_typed';
@@ -28,18 +27,18 @@ import {SharedStylesHost} from "angular2/src/platform/dom/shared_styles_host";
import {CompA} from './offline_compiler_util';
export function main() {
- var outputDefs = [];
var typedComponentFactory = typed.CompANgFactory;
var untypedComponentFactory = untyped.CompANgFactory;
+ var fixtures: TestFixture[] = [];
if (IS_DART || !DOM.supportsDOMEvents()) {
// Our generator only works on node.js and Dart...
- outputDefs.push({'compAHostComponentFactory': typedComponentFactory, 'name': 'typed'});
+ fixtures.push(new TestFixture(typedComponentFactory, 'typed'));
}
if (!IS_DART) {
// Our generator only works on node.js and Dart...
if (!DOM.supportsDOMEvents()) {
- outputDefs.push({'compAHostComponentFactory': untypedComponentFactory, 'name': 'untyped'});
+ fixtures.push(new TestFixture(untypedComponentFactory, 'untyped'));
}
}
describe('OfflineCompiler', () => {
@@ -51,16 +50,11 @@ export function main() {
sharedStylesHost = _sharedStylesHost;
}));
- function createHostComp(cf: ComponentFactory): DebugElement {
- var compRef = cf.create(injector);
- return getDebugNode(compRef.location.nativeElement);
- }
-
- outputDefs.forEach((outputDef) => {
- describe(`${outputDef['name']}`, () => {
+ fixtures.forEach((fixture) => {
+ describe(`${fixture.name}`, () => {
it('should compile components', () => {
- var hostEl = createHostComp(outputDef['compAHostComponentFactory']);
- expect(hostEl.componentInstance).toBeAnInstanceOf(CompA);
+ var hostEl = fixture.compFactory.create(injector);
+ expect(hostEl.instance).toBeAnInstanceOf(CompA);
var styles = sharedStylesHost.getAllStyles();
expect(styles[0]).toContain('.redStyle[_ngcontent');
expect(styles[1]).toContain('.greenStyle[_ngcontent');
@@ -68,4 +62,8 @@ export function main() {
});
});
});
+}
+
+class TestFixture {
+ constructor(public compFactory: ComponentFactory, public name: string) {}
}
\ No newline at end of file
diff --git a/modules/angular2/test/core/application_ref_spec.ts b/modules/angular2/test/core/application_ref_spec.ts
index 107241c127..674a941841 100644
--- a/modules/angular2/test/core/application_ref_spec.ts
+++ b/modules/angular2/test/core/application_ref_spec.ts
@@ -50,7 +50,7 @@ export function main() {
describe("bootstrap", () => {
var platform: PlatformRef;
var errorLogger: _ArrayLogger;
- var someCompFactory: ComponentFactory;
+ var someCompFactory: ComponentFactory;
beforeEach(() => {
errorLogger = new _ArrayLogger();
@@ -153,24 +153,24 @@ class _ArrayLogger {
logGroupEnd(){};
}
-class _MockComponentFactory extends ComponentFactory {
- constructor(private _compRef: ComponentRef) { super(null, null, null); }
+class _MockComponentFactory extends ComponentFactory {
+ constructor(private _compRef: ComponentRef) { super(null, null, null); }
create(injector: Injector, projectableNodes: any[][] = null,
- rootSelectorOrNode: string | any = null): ComponentRef {
+ rootSelectorOrNode: string | any = null): ComponentRef {
return this._compRef;
}
}
class _MockComponentResolver implements ComponentResolver {
- constructor(private _compFactory: ComponentFactory) {}
+ constructor(private _compFactory: ComponentFactory) {}
- resolveComponent(type: Type): Promise {
+ resolveComponent(type: Type): Promise> {
return PromiseWrapper.resolve(this._compFactory);
}
clearCache() {}
}
-class _MockComponentRef extends ComponentRef_ {
+class _MockComponentRef extends ComponentRef_ {
constructor(private _injector: Injector) { super(null, null); }
get injector(): Injector { return this._injector; }
get changeDetectorRef(): ChangeDetectorRef { return new SpyChangeDetectorRef(); }
diff --git a/modules/angular2/test/core/linker/change_detection_integration_spec.ts b/modules/angular2/test/core/linker/change_detection_integration_spec.ts
index 8dc5aaad2a..5fc9e0ba0e 100644
--- a/modules/angular2/test/core/linker/change_detection_integration_spec.ts
+++ b/modules/angular2/test/core/linker/change_detection_integration_spec.ts
@@ -82,7 +82,7 @@ export function main() {
var directiveLog: DirectiveLog;
function createCompFixture(template: string, compType: Type = TestComponent,
- _tcb: TestComponentBuilder = null): ComponentFixture {
+ _tcb: TestComponentBuilder = null): ComponentFixture {
if (isBlank(_tcb)) {
_tcb = tcb;
}
@@ -98,12 +98,14 @@ export function main() {
return nodes.map(node => node.inject(dirType));
}
- function _bindSimpleProp(bindAttr: string, compType: Type = TestComponent): ComponentFixture {
+ function _bindSimpleProp(bindAttr: string,
+ compType: Type = TestComponent): ComponentFixture {
var template = ``;
return createCompFixture(template, compType);
}
- function _bindSimpleValue(expression: any, compType: Type = TestComponent): ComponentFixture {
+ function _bindSimpleValue(expression: any,
+ compType: Type = TestComponent): ComponentFixture {
return _bindSimpleProp(`[someProp]='${expression}'`, compType);
}
@@ -640,7 +642,7 @@ export function main() {
});
describe('lifecycle', () => {
- function createCompWithContentAndViewChild(): ComponentFixture {
+ function createCompWithContentAndViewChild(): ComponentFixture {
return createCompFixture(
'',
TestComponent,
diff --git a/modules/angular2/test/core/linker/dynamic_component_loader_spec.ts b/modules/angular2/test/core/linker/dynamic_component_loader_spec.ts
index 3dfc54ea9f..6a5567e474 100644
--- a/modules/angular2/test/core/linker/dynamic_component_loader_spec.ts
+++ b/modules/angular2/test/core/linker/dynamic_component_loader_spec.ts
@@ -94,7 +94,7 @@ export function main() {
it('should leave the view tree in a consistent state if hydration fails',
inject([DynamicComponentLoader, TestComponentBuilder, AsyncTestCompleter],
(loader: DynamicComponentLoader, tcb: TestComponentBuilder, async) => {
- tcb.createAsync(MyComp).then((tc: ComponentFixture) => {
+ tcb.createAsync(MyComp).then((tc: ComponentFixture) => {
tc.detectChanges();
PromiseWrapper.catchError(
loader.loadNextToLocation(DynamicallyLoadedThrows,
@@ -146,7 +146,7 @@ export function main() {
DOM.appendChild(doc.body, rootEl);
loader.loadAsRoot(ChildComp, null, injector)
.then((componentRef) => {
- var el = new ComponentFixture(componentRef, null, false);
+ var el = new ComponentFixture(componentRef, null, false);
expect(rootEl.parentNode).toBe(doc.body);
diff --git a/modules/angular2/test/core/linker/integration_spec.ts b/modules/angular2/test/core/linker/integration_spec.ts
index 720ba3513f..010946a20f 100644
--- a/modules/angular2/test/core/linker/integration_spec.ts
+++ b/modules/angular2/test/core/linker/integration_spec.ts
@@ -770,14 +770,13 @@ function declareTests(isJit: boolean) {
it("should allow to destroy a component from within a host event handler",
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- var fixture: ComponentFixture;
- tcb.overrideView(MyComp, new ViewMetadata({
- template: '',
- directives: [[[PushCmpWithHostEvent]]]
- }))
-
- .createAsync(MyComp)
- .then(root => { fixture = root; });
+ let fixture =
+ tcb.overrideView(
+ MyComp, new ViewMetadata({
+ template: '',
+ directives: [[[PushCmpWithHostEvent]]]
+ }))
+ .createFakeAsync(MyComp);
tick();
fixture.detectChanges();
@@ -865,8 +864,7 @@ function declareTests(isJit: boolean) {
directives: [[[PushCmpWithAsyncPipe]]]
}));
- var fixture: ComponentFixture;
- tcb.createAsync(MyComp).then(root => { fixture = root; });
+ let fixture = tcb.createFakeAsync(MyComp);
tick();
var cmp: PushCmpWithAsyncPipe = fixture.debugElement.children[0].references['cmp'];
@@ -1500,8 +1498,7 @@ function declareTests(isJit: boolean) {
directives: [DirectiveEmittingEvent, DirectiveListeningEvent]
}));
- var fixture: ComponentFixture;
- tcb.createAsync(MyComp).then(root => { fixture = root; });
+ let fixture = tcb.createFakeAsync(MyComp);
tick();
var tc = fixture.debugElement.children[0];
@@ -1606,7 +1603,7 @@ function declareTests(isJit: boolean) {
directives: [SomeImperativeViewport]
}))
.createAsync(MyComp)
- .then((fixture: ComponentFixture) => {
+ .then((fixture: ComponentFixture) => {
fixture.detectChanges();
expect(anchorElement).toHaveText('');
@@ -1828,8 +1825,7 @@ function declareTests(isJit: boolean) {
directives: [DirectiveWithPropDecorators]
}));
- var fixture: ComponentFixture;
- tcb.createAsync(MyComp).then(root => { fixture = root; });
+ let fixture = tcb.createFakeAsync(MyComp);
tick();
var emitter = fixture.debugElement.children[0].inject(DirectiveWithPropDecorators);
diff --git a/modules/angular2/test/core/linker/projection_integration_spec.ts b/modules/angular2/test/core/linker/projection_integration_spec.ts
index 66f82f6795..cfe96a9275 100644
--- a/modules/angular2/test/core/linker/projection_integration_spec.ts
+++ b/modules/angular2/test/core/linker/projection_integration_spec.ts
@@ -293,7 +293,7 @@ export function main() {
{template: '', directives: [Simple]}))
.overrideTemplate(Simple, 'P,
{{stringProp}}')
.createAsync(MainComp)
- .then((main: ComponentFixture) => {
+ .then((main: ComponentFixture) => {
main.detectChanges();
@@ -314,7 +314,7 @@ export function main() {
{template: '', directives: [Simple]}))
.overrideTemplate(Simple, 'P,
{{stringProp}}')
.createAsync(MainComp)
- .then((main: ComponentFixture) => {
+ .then((main: ComponentFixture) => {
main.detectChanges();
expect(main.debugElement.nativeElement).toHaveText('P,text');
diff --git a/modules/angular2/test/core/linker/reflector_component_resolver_spec.ts b/modules/angular2/test/core/linker/reflector_component_resolver_spec.ts
index 48715f415d..e81706f2ce 100644
--- a/modules/angular2/test/core/linker/reflector_component_resolver_spec.ts
+++ b/modules/angular2/test/core/linker/reflector_component_resolver_spec.ts
@@ -35,7 +35,7 @@ export function main() {
it('should read the template from an annotation',
inject([AsyncTestCompleter, ComponentResolver], (async, compiler: ComponentResolver) => {
compiler.resolveComponent(SomeComponent)
- .then((compFactory: ComponentFactory) => {
+ .then((compFactory: ComponentFactory) => {
expect(compFactory).toBe(someCompFactory);
async.done();
return null;
diff --git a/modules/angular2/test/core/linker/view_injector_integration_spec.ts b/modules/angular2/test/core/linker/view_injector_integration_spec.ts
index e29ebe2625..eeff6a620e 100644
--- a/modules/angular2/test/core/linker/view_injector_integration_spec.ts
+++ b/modules/angular2/test/core/linker/view_injector_integration_spec.ts
@@ -274,7 +274,7 @@ export function main() {
var tcb: TestComponentBuilder;
function createCompFixture(template: string, tcb: TestComponentBuilder,
- comp: Type = null): ComponentFixture {
+ comp: Type = null): ComponentFixture {
if (isBlank(comp)) {
comp = TestComp;
}
diff --git a/modules/angular2/test/platform/browser/bootstrap_spec.ts b/modules/angular2/test/platform/browser/bootstrap_spec.ts
index f6c47f431a..3d7a03c64e 100644
--- a/modules/angular2/test/platform/browser/bootstrap_spec.ts
+++ b/modules/angular2/test/platform/browser/bootstrap_spec.ts
@@ -262,11 +262,11 @@ export function main() {
it('should register each application with the testability registry',
inject([AsyncTestCompleter], (async) => {
- var refPromise1: Promise = bootstrap(HelloRootCmp, testProviders);
- var refPromise2: Promise = bootstrap(HelloRootCmp2, testProviders);
+ var refPromise1: Promise> = bootstrap(HelloRootCmp, testProviders);
+ var refPromise2: Promise> = bootstrap(HelloRootCmp2, testProviders);
PromiseWrapper.all([refPromise1, refPromise2])
- .then((refs: ComponentRef[]) => {
+ .then((refs: ComponentRef[]) => {
var registry = refs[0].injector.get(TestabilityRegistry);
var testabilities =
[refs[0].injector.get(Testability), refs[1].injector.get(Testability)];
diff --git a/modules/angular2/test/platform/browser/tools/spies.dart b/modules/angular2/test/platform/browser/tools/spies.dart
index 5a76e1403b..bb069be302 100644
--- a/modules/angular2/test/platform/browser/tools/spies.dart
+++ b/modules/angular2/test/platform/browser/tools/spies.dart
@@ -11,7 +11,7 @@ class SpyApplicationRef extends SpyObject implements ApplicationRef {
}
@proxy
-class SpyComponentRef extends SpyObject implements ComponentRef {
+class SpyComponentRef extends SpyObject implements ComponentRef {
Injector injector;
SpyComponentRef() {
diff --git a/modules/angular2/test/platform/browser/xhr_cache_spec.ts b/modules/angular2/test/platform/browser/xhr_cache_spec.ts
index cfd3252b76..9ff794429c 100644
--- a/modules/angular2/test/platform/browser/xhr_cache_spec.ts
+++ b/modules/angular2/test/platform/browser/xhr_cache_spec.ts
@@ -59,8 +59,7 @@ export function main() {
it('should allow fakeAsync Tests to load components with templateUrl synchronously',
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
- let fixture: ComponentFixture;
- tcb.createAsync(TestComponent).then((f) => { fixture = f; });
+ let fixture = tcb.createFakeAsync(TestComponent);
// This should initialize the fixture.
tick();
diff --git a/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts b/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts
index d3fdb8c5c8..0939e5bb42 100644
--- a/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts
+++ b/modules/angular2/test/router/integration/impl/async_route_spec_impl.ts
@@ -35,7 +35,7 @@ import {
asyncRouteDataCmp
} from './fixture_components';
-function getLinkElement(rtc: ComponentFixture) {
+function getLinkElement(rtc: ComponentFixture) {
return rtc.debugElement.query(By.css('a')).nativeElement;
}
diff --git a/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts b/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts
index af0edeba2b..0eaed3362d 100644
--- a/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts
+++ b/modules/angular2/test/router/integration/impl/aux_route_spec_impl.ts
@@ -30,13 +30,13 @@ import {
import {specs, compile, clickOnElement, getHref} from '../util';
import {BaseException} from 'angular2/src/facade/exceptions';
-function getLinkElement(rtc: ComponentFixture, linkIndex: number = 0) {
+function getLinkElement(rtc: ComponentFixture, linkIndex: number = 0) {
return rtc.debugElement.queryAll(By.css('a'))[linkIndex].nativeElement;
}
function auxRoutes() {
var tcb: TestComponentBuilder;
- var fixture: ComponentFixture;
+ var fixture: ComponentFixture;
var rtr;
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
@@ -139,7 +139,7 @@ function auxRoutes() {
function auxRoutesWithAPrimaryRoute() {
var tcb: TestComponentBuilder;
- var fixture: ComponentFixture;
+ var fixture: ComponentFixture;
var rtr;
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
diff --git a/modules/angular2/test/router/integration/impl/fixture_components.ts b/modules/angular2/test/router/integration/impl/fixture_components.ts
index a48a271e8d..660605439c 100644
--- a/modules/angular2/test/router/integration/impl/fixture_components.ts
+++ b/modules/angular2/test/router/integration/impl/fixture_components.ts
@@ -142,7 +142,7 @@ export class RedirectToParentCmp {
@Component({selector: 'dynamic-loader-cmp', template: `{ }`})
@RouteConfig([new Route({path: '/', component: HelloCmp})])
export class DynamicLoaderCmp {
- private _componentRef: ComponentRef = null;
+ private _componentRef: ComponentRef = null;
@ViewChild('viewport', {read: ViewContainerRef}) viewport: ViewContainerRef;
diff --git a/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts b/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts
index 4818dc2118..16dec59065 100644
--- a/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts
+++ b/modules/angular2/test/router/integration/impl/sync_route_spec_impl.ts
@@ -30,7 +30,7 @@ import {
import {PromiseWrapper} from 'angular2/src/facade/async';
-function getLinkElement(rtc: ComponentFixture) {
+function getLinkElement(rtc: ComponentFixture) {
return rtc.debugElement.query(By.css('a')).nativeElement;
}
@@ -431,7 +431,7 @@ function syncRoutesWithSyncChildrenWithDefaultRoutesWithoutParams() {
}
function syncRoutesWithDynamicComponents() {
- var fixture: ComponentFixture;
+ var fixture: ComponentFixture;
var tcb: TestComponentBuilder;
var rtr: Router;
diff --git a/modules/angular2/test/router/integration/lifecycle_hook_spec.ts b/modules/angular2/test/router/integration/lifecycle_hook_spec.ts
index 98df7f8335..9f6d9dfacd 100644
--- a/modules/angular2/test/router/integration/lifecycle_hook_spec.ts
+++ b/modules/angular2/test/router/integration/lifecycle_hook_spec.ts
@@ -55,7 +55,7 @@ export function main() {
describe('Router lifecycle hooks', () => {
var tcb: TestComponentBuilder;
- var fixture: ComponentFixture;
+ var fixture: ComponentFixture;
var rtr: Router;
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
diff --git a/modules/angular2/test/router/integration/navigation_spec.ts b/modules/angular2/test/router/integration/navigation_spec.ts
index 8e97d59269..1cd317938d 100644
--- a/modules/angular2/test/router/integration/navigation_spec.ts
+++ b/modules/angular2/test/router/integration/navigation_spec.ts
@@ -37,7 +37,7 @@ export function main() {
describe('navigation', () => {
var tcb: TestComponentBuilder;
- var fixture: ComponentFixture;
+ var fixture: ComponentFixture;
var rtr;
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
diff --git a/modules/angular2/test/router/integration/redirect_route_spec.ts b/modules/angular2/test/router/integration/redirect_route_spec.ts
index 1049ff0d12..50f6cf85ce 100644
--- a/modules/angular2/test/router/integration/redirect_route_spec.ts
+++ b/modules/angular2/test/router/integration/redirect_route_spec.ts
@@ -35,7 +35,7 @@ export function main() {
describe('redirects', () => {
var tcb: TestComponentBuilder;
- var rootTC: ComponentFixture;
+ var rootTC: ComponentFixture;
var rtr;
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
diff --git a/modules/angular2/test/router/integration/router_link_spec.ts b/modules/angular2/test/router/integration/router_link_spec.ts
index 7d926f687a..696f8b1f27 100644
--- a/modules/angular2/test/router/integration/router_link_spec.ts
+++ b/modules/angular2/test/router/integration/router_link_spec.ts
@@ -47,7 +47,7 @@ import {RouterLinkTransform} from 'angular2/src/router/directives/router_link_tr
export function main() {
describe('routerLink directive', function() {
var tcb: TestComponentBuilder;
- var fixture: ComponentFixture;
+ var fixture: ComponentFixture;
var router: Router;
var location: Location;
@@ -373,7 +373,7 @@ export function main() {
});
}
-function getHref(tc: ComponentFixture) {
+function getHref(tc: ComponentFixture) {
return DOM.getAttribute(tc.debugElement.query(By.css('a')).nativeElement, 'href');
}
diff --git a/modules/angular2/test/testing/test_component_builder_spec.ts b/modules/angular2/test/testing/test_component_builder_spec.ts
index 295ed4e705..d91d4a18cc 100644
--- a/modules/angular2/test/testing/test_component_builder_spec.ts
+++ b/modules/angular2/test/testing/test_component_builder_spec.ts
@@ -17,7 +17,7 @@ import {
ComponentFixtureNoNgZone
} from 'angular2/testing_internal';
-import {Injectable, provide} from 'angular2/core';
+import {Injectable, provide, ComponentResolver} from 'angular2/core';
import {NgIf} from 'angular2/common';
import {Directive, Component, ViewMetadata, Input} from 'angular2/src/core/metadata';
import {IS_DART} from 'angular2/src/facade/lang';
@@ -460,6 +460,27 @@ export function main() {
});
}));
});
+
+ describe('createSync', () => {
+ it('should create components',
+ inject([ComponentResolver, TestComponentBuilder, AsyncTestCompleter],
+ (cr: ComponentResolver, tcb: TestComponentBuilder, async) => {
+ cr.resolveComponent(MyIfComp).then((cmpFactory) => {
+ let componentFixture = tcb.createSync(cmpFactory);
+
+ componentFixture.detectChanges();
+ expect(componentFixture.nativeElement).toHaveText('MyIf()');
+
+ componentFixture.componentInstance.showMore = true;
+ componentFixture.detectChanges();
+ expect(componentFixture.nativeElement).toHaveText('MyIf(More)');
+
+ async.done();
+ });
+ }));
+
+ });
+
});
}
});
diff --git a/modules/angular2/test/web_workers/worker/renderer_integration_spec.ts b/modules/angular2/test/web_workers/worker/renderer_integration_spec.ts
index dc782c396f..c55ca1f14a 100644
--- a/modules/angular2/test/web_workers/worker/renderer_integration_spec.ts
+++ b/modules/angular2/test/web_workers/worker/renderer_integration_spec.ts
@@ -120,7 +120,7 @@ export function main() {
return uiRenderStore.deserialize(id);
}
- function getRenderer(componentRef: ComponentRef) {
+ function getRenderer(componentRef: ComponentRef) {
return (componentRef.hostView).internalView.renderer;
}
diff --git a/tools/public_api_guard/public_api_spec.ts b/tools/public_api_guard/public_api_spec.ts
index f7975fa70d..848bf60328 100644
--- a/tools/public_api_guard/public_api_spec.ts
+++ b/tools/public_api_guard/public_api_spec.ts
@@ -29,11 +29,11 @@ const CORE = [
'AfterViewInit',
'AfterViewInit.ngAfterViewInit():any',
'ApplicationRef',
- 'ApplicationRef.bootstrap(componentFactory:ComponentFactory):ComponentRef',
+ 'ApplicationRef.bootstrap(componentFactory:ComponentFactory):ComponentRef',
'ApplicationRef.componentTypes:Type[]',
'ApplicationRef.dispose():void',
'ApplicationRef.injector:Injector',
- 'ApplicationRef.registerBootstrapListener(listener:(ref: ComponentRef) => void):void',
+ 'ApplicationRef.registerBootstrapListener(listener:(ref: ComponentRef) => void):void',
'ApplicationRef.registerDisposeListener(dispose:() => void):void',
'ApplicationRef.tick():void',
'ApplicationRef.run(callback:Function):any',
@@ -74,7 +74,7 @@ const CORE = [
'CollectionChangeRecord.toString():string',
'ComponentResolver',
'ComponentResolver.clearCache():any',
- 'ComponentResolver.resolveComponent(componentType:Type):Promise',
+ 'ComponentResolver.resolveComponent(componentType:Type):Promise>',
'ComponentDecorator',
'ComponentDecorator.View(obj:{templateUrl?:string, template?:string, directives?:Array, pipes?:Array, renderer?:string, styles?:string[], styleUrls?:string[]}):ViewDecorator',
'ComponentMetadataFactory',
@@ -91,10 +91,10 @@ const CORE = [
'ComponentMetadata.templateUrl:string',
'ComponentMetadata.viewBindings:any[]',
'ComponentMetadata.viewProviders:any[]',
- 'ComponentRef',
+ 'ComponentRef',
'ComponentRef.componentType:Type',
'ComponentRef.injector:Injector',
- 'ComponentRef.instance:any',
+ 'ComponentRef.instance:C',
'ComponentRef.location:ElementRef',
'ComponentRef.destroy():void',
'ComponentRef.hostView:ViewRef',
@@ -159,8 +159,8 @@ const CORE = [
'DoCheck',
'DoCheck.ngDoCheck():any',
'DynamicComponentLoader',
- 'DynamicComponentLoader.loadAsRoot(type:Type, overrideSelectorOrNode:string|any, injector:Injector, onDispose:() => void, projectableNodes:any[][]):Promise',
- 'DynamicComponentLoader.loadNextToLocation(type:Type, location:ViewContainerRef, providers:ResolvedReflectiveProvider[], projectableNodes:any[][]):Promise',
+ 'DynamicComponentLoader.loadAsRoot(type:Type, overrideSelectorOrNode:string|any, injector:Injector, onDispose:() => void, projectableNodes:any[][]):Promise>',
+ 'DynamicComponentLoader.loadNextToLocation(type:Type, location:ViewContainerRef, providers:ResolvedReflectiveProvider[], projectableNodes:any[][]):Promise>',
'ElementRef',
'ElementRef.nativeElement:any',
'ElementRef.constructor(nativeElement:any)',
@@ -192,10 +192,10 @@ const CORE = [
'HostListenerMetadata.constructor(eventName:string, args:string[])',
'HostMetadata',
'HostMetadata.toString():string',
- 'ComponentFactory',
+ 'ComponentFactory',
'ComponentFactory.componentType:Type',
'ComponentFactory.constructor(selector:string, _viewFactory:Function, _componentType:Type)',
- 'ComponentFactory.create(injector:Injector, projectableNodes:any[][], rootSelectorOrNode:string|any):ComponentRef',
+ 'ComponentFactory.create(injector:Injector, projectableNodes:any[][], rootSelectorOrNode:string|any):ComponentRef',
'InjectMetadataFactory',
'InjectMetadata',
'InjectMetadata.constructor(token:any)',
@@ -445,8 +445,8 @@ const CORE = [
'ViewChildrenMetadata.constructor(_selector:Type|string, {read=null}:{read?:any})',
'ViewContainerRef',
'ViewContainerRef.clear():void',
- 'ViewContainerRef.createEmbeddedView(templateRef:TemplateRef, context:any, index:number):EmbeddedViewRef',
- 'ViewContainerRef.createComponent(componentFactory:ComponentFactory, index:number, injector:Injector, projectableNodes:any[][]):ComponentRef',
+ 'ViewContainerRef.createEmbeddedView(templateRef:TemplateRef, context:C, index:number):EmbeddedViewRef',
+ 'ViewContainerRef.createComponent(componentFactory:ComponentFactory, index:number, injector:Injector, projectableNodes:any[][]):ComponentRef',
'ViewContainerRef.detach(index:number):ViewRef',
'ViewContainerRef.element:ElementRef',
'ViewContainerRef.injector:Injector',
@@ -503,8 +503,8 @@ const CORE = [
'createNgZone():NgZone',
'enableProdMode():any',
'forwardRef(forwardRefFn:ForwardRefFn):Type',
- 'coreBootstrap(injector:Injector, componentFactory:ComponentFactory):ComponentRef',
- 'coreLoadAndBootstrap(injector:Injector, componentType:Type):Promise',
+ 'coreBootstrap(injector:Injector, componentFactory:ComponentFactory):ComponentRef',
+ 'coreLoadAndBootstrap(injector:Injector, componentType:Type):Promise>',
'assertPlatform(requiredToken:any):PlatformRef',
'createPlatform(injector:Injector):PlatformRef',
'disposePlatform():void',
@@ -1208,13 +1208,13 @@ const BROWSER = [
'Title',
'Title.getTitle():string',
'Title.setTitle(newTitle:string):any',
- 'bootstrapStatic(appComponentType:Type, customProviders:Array, initReflector:Function):Promise',
+ 'bootstrapStatic(appComponentType:Type, customProviders:Array, initReflector:Function):Promise>',
'const BROWSER_APP_PROVIDERS:Array',
'const BROWSER_PROVIDERS:Array',
'const ELEMENT_PROBE_PROVIDERS:any[]',
'const ELEMENT_PROBE_PROVIDERS_PROD_MODE:any[]',
'disableDebugTools():void',
- 'enableDebugTools(ref:ComponentRef):void',
+ 'enableDebugTools(ref:ComponentRef):void',
'inspectNativeElement(element:any):DebugNode',
'browserStaticPlatform():PlatformRef'
];