fix(element_injector): inject the containing change detector ref to directives

This commit is contained in:
vsavkin
2015-07-15 13:25:17 -07:00
parent f7dfd2325d
commit 7879761a41
2 changed files with 30 additions and 6 deletions

View File

@ -589,8 +589,10 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
var key: Key = dep.key;
if (!(dep instanceof DirectiveDependency)) return undefinedValue;
if (!(binding instanceof DirectiveBinding)) return undefinedValue;
var dirDep = <DirectiveDependency>dep;
var dirBin = <DirectiveBinding>binding;
var staticKeys = StaticKeys.instance();
@ -601,8 +603,12 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
if (isPresent(dirDep.queryDecorator)) return this._findQuery(dirDep.queryDecorator).list;
if (dirDep.key.id === StaticKeys.instance().changeDetectorRefId) {
var componentView = this._preBuiltObjects.view.componentChildViews[this._proto.index];
return componentView.changeDetector.ref;
if (dirBin.metadata.type === DirectiveMetadata.COMPONENT_TYPE) {
var componentView = this._preBuiltObjects.view.componentChildViews[this._proto.index];
return componentView.changeDetector.ref;
} else {
return this._preBuiltObjects.view.changeDetector.ref;
}
}
if (dirDep.key.id === StaticKeys.instance().elementRefId) {