fix(life_cycle): remove cyclic dependency

fixes #477

Closes #530
This commit is contained in:
Bertrand Laporte
2015-02-03 17:05:29 -08:00
committed by Misko Hevery
parent 5010cf9757
commit 63f23ec0b6
3 changed files with 40 additions and 8 deletions

View File

@ -7,6 +7,7 @@ import {ListWrapper} from 'angular2/src/facade/collection';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {bind, Inject} from 'angular2/di';
import {TemplateConfig} from 'angular2/src/core/annotations/template_config';
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
@Component({
selector: 'hello-app',
@ -51,6 +52,21 @@ class HelloRootCmp3 {
}
}
@Component({
selector: 'hello-app',
template: new TemplateConfig({
inline: '',
directives: []
})
})
class HelloRootCmp4 {
lc;
constructor(@Inject(LifeCycle) lc) {
this.lc = lc;
}
}
export function main() {
var fakeDoc, el, el2, testBindings;
@ -126,5 +142,14 @@ export function main() {
done();
});
});
it("should avoid cyclic dependencies when root component requires Lifecycle through DI", (done) => {
var injectorPromise = bootstrap(HelloRootCmp4, testBindings);
injectorPromise.then((injector) => {
expect(injector.get(HelloRootCmp4).lc).toBe(injector.get(LifeCycle));
done();
});
});
});
}