You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Directive({
selector: '[container]'
})
class Container {
items: QueryList<Item>;
constructor(@Query(Item, {descendants: true}) items: QueryList<Item>) {
this.items = items;
this.items.changes.toRx().subscribe((list) => {
// list is always empty!
// this.items is also always empty!
});
}
}
@Directive({
selector: '[item]'
})
class Item {
@Input() item: string;
constructor(private el: ElementRef) {
...
}
}
and markup like...
// given a bootstrapped component like...
@Component({
selector: 'app',
template: `
<section container>
<div *ng-for="#item of items" item>
</div>
</section>
`,
directives: [Container, Item]
})
export class AppCmp {
public items: Array<any> = [ .... ]; // items omitted for example here, but this would be full of 20 objects
}
bootstrap(AppCmp, []);
Not sure if I am using it wrong or if this is a bug in alpha45.
The text was updated successfully, but these errors were encountered:
I am in the process of building an Angular2 library to be shared with the community via npm and stumped with
QueryList
. It always returns an empty list of items upon instantiation and when subscribing to it. Pseudo code to follow.I've read and followed all the documentation here:
https://angular.io/docs/ts/latest/api/core/QueryList-class.html
https://angular.io/docs/ts/latest/api/core/QueryMetadata-class.html
(...and all other docs realted to query, etc.)
As well as read:
http://victorsavkin.com/post/126514197956/dependency-injection-in-angular-1-and-angular-2
And tried using
@ContentChildren
as well to no avail.Given directives similar to following...
and markup like...
Not sure if I am using it wrong or if this is a bug in alpha45.
The text was updated successfully, but these errors were encountered: