refactor(core): introduce ComponentFactory.
Each compile template now exposes a `<CompName>NgFactory` variable with an instance of a `ComponentFactory`. Calling `ComponentFactory.create` returns a `ComponentRef` that can be used directly. BREAKING CHANGE: - `Compiler` is renamed to `ComponentResolver`, `Compiler.compileInHost` has been renamed to `ComponentResolver.resolveComponent`. - `ComponentRef.dispose` is renamed to `ComponentRef.destroy` - `ViewContainerRef.createHostView` is renamed to `ViewContainerRef.createComponent` - `ComponentFixture_` has been removed, the class `ComponentFixture` can now be created directly as it is no more using private APIs.
This commit is contained in:
@ -69,10 +69,10 @@ export function main() {
|
||||
provide(Console, {useClass: DummyConsole})
|
||||
])
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('outer { hello }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('');
|
||||
expect(applicationRef.instance.location.path()).toEqual('');
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {Component, ComponentRef} from 'angular2/core';
|
||||
import {
|
||||
AsyncRoute,
|
||||
Route,
|
||||
@ -10,10 +10,7 @@ import {
|
||||
} from 'angular2/router';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {isPresent} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
DynamicComponentLoader,
|
||||
ComponentRef
|
||||
} from 'angular2/src/core/linker/dynamic_component_loader';
|
||||
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
|
||||
import {ElementRef} from 'angular2/src/core/linker/element_ref';
|
||||
|
||||
@Component({selector: 'goodbye-cmp', template: `{{farewell}}`})
|
||||
@ -152,7 +149,7 @@ export class DynamicLoaderCmp {
|
||||
|
||||
onSomeAction(): Promise<any> {
|
||||
if (isPresent(this._componentRef)) {
|
||||
this._componentRef.dispose();
|
||||
this._componentRef.destroy();
|
||||
this._componentRef = null;
|
||||
}
|
||||
return this._dynamicComponentLoader.loadIntoLocation(DynamicallyLoadedComponent,
|
||||
|
@ -58,10 +58,10 @@ export function main() {
|
||||
it('should bootstrap an app with a hierarchy', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(HierarchyAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('root { parent { hello } }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/parent/child');
|
||||
expect(applicationRef.instance.location.path()).toEqual('/parent/child');
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/parent/child');
|
||||
@ -72,10 +72,10 @@ export function main() {
|
||||
it('should work in an app with redirects', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(RedirectAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('root { hello }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/after');
|
||||
expect(applicationRef.instance.location.path()).toEqual('/after');
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/before');
|
||||
@ -86,10 +86,10 @@ export function main() {
|
||||
it('should work in an app with async components', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(AsyncAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('root { hello }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/hello');
|
||||
expect(applicationRef.instance.location.path()).toEqual('/hello');
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/hello');
|
||||
@ -100,10 +100,10 @@ export function main() {
|
||||
it('should work in an app with aux routes', inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(AuxAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('root { hello } aside { hello }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/hello(aside)');
|
||||
expect(applicationRef.instance.location.path()).toEqual('/hello(aside)');
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/hello(aside)');
|
||||
@ -115,10 +115,10 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(ConciseAsyncAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('root { hello }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/hello');
|
||||
expect(applicationRef.instance.location.path()).toEqual('/hello');
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/hello');
|
||||
@ -130,10 +130,10 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(ExplicitConstructorAppCmp, testBindings)
|
||||
.then((applicationRef) => {
|
||||
var router = applicationRef.hostComponent.router;
|
||||
var router = applicationRef.instance.router;
|
||||
router.subscribe((_) => {
|
||||
expect(el).toHaveText('root { hello }');
|
||||
expect(applicationRef.hostComponent.location.path()).toEqual('/hello');
|
||||
expect(applicationRef.instance.location.path()).toEqual('/hello');
|
||||
async.done();
|
||||
});
|
||||
router.navigateByUrl('/hello');
|
||||
|
Reference in New Issue
Block a user