fix(compiler): Query expression lambdas should have dynamic type

Fixes: #9875
This commit is contained in:
Chuck Jazdzewski 2016-07-13 10:55:23 -07:00
parent 9229bbbc80
commit 961c9d48ae
2 changed files with 23 additions and 4 deletions

View File

@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core';
import {NgFor} from '@angular/common';
import {Component, Directive, QueryList, ViewChild, ViewChildren} from '@angular/core';
@Component({selector: 'comp-for-child-query', template: 'child'})
export class CompForChildQuery {
@ -21,3 +22,20 @@ export class CompWithChildQuery {
@ViewChild(CompForChildQuery) child: CompForChildQuery;
@ViewChildren(CompForChildQuery) children: QueryList<CompForChildQuery>;
}
@Directive({selector: '[directive-for-query]'})
export class DirectiveForQuery {
}
@Component({
selector: 'comp-with-directive-child',
directives: [DirectiveForQuery, NgFor],
template: `<div>
<div *ngFor="let data of divData" directive-for-query>{{data}}</div>
</div>`
})
export class CompWithDirectiveChild {
@ViewChildren(DirectiveForQuery) children: QueryList<DirectiveForQuery>;
divData: string[];
}

View File

@ -105,9 +105,10 @@ function mapNestedViews(
return o.replaceVarInExpression(o.THIS_EXPR.name, o.variable('nestedView'), expr);
});
return declarationAppElement.callMethod('mapNestedViews', [
o.variable(view.className), o.fn(
[new o.FnParam('nestedView', view.classType)],
[new o.ReturnStatement(o.literalArr(adjustedExpressions))])
o.variable(view.className),
o.fn(
[new o.FnParam('nestedView', view.classType)],
[new o.ReturnStatement(o.literalArr(adjustedExpressions))], o.DYNAMIC_TYPE)
]);
}