Skip to content

Commit

Permalink
fix(query): the view should not be visible to @query.
Browse files Browse the repository at this point in the history
@ViewQuery is the correct way to query the view template.
  • Loading branch information
rkirov committed Jul 28, 2015
1 parent 448ca38 commit 1d45029
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions modules/angular2/src/core/compiler/element_injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,14 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
}

private _addViewQueries(host: ElementInjector): void {
if (isPresent(host._query0) && host._query0.originator == host)
if (isPresent(host._query0) && host._query0.originator == host &&
host._query0.query.isViewQuery)
this._addViewQuery(host._query0);
if (isPresent(host._query1) && host._query1.originator == host)
if (isPresent(host._query1) && host._query1.originator == host &&
host._query1.query.isViewQuery)
this._addViewQuery(host._query1);
if (isPresent(host._query2) && host._query2.originator == host)
if (isPresent(host._query2) && host._query2.originator == host &&
host._query2.query.isViewQuery)
this._addViewQuery(host._query2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ class TextDirective {
}

@Component({selector: 'needs-query'})
@View({directives: [NgFor], template: '<div *ng-for="var dir of query">{{dir.text}}|</div>'})
@View({
directives: [NgFor, TextDirective],
template: '<div text="ignoreme"></div><div *ng-for="var dir of query">{{dir.text}}|</div>'
})
@Injectable()
class NeedsQuery {
query: QueryList<TextDirective>;
Expand Down

0 comments on commit 1d45029

Please sign in to comment.