O'Reilly logo

Angular 2 Cookbook by Matt Frisbie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using QueryLists and Observables to follow changes in ViewChildren

One very useful piece of behavior in components is the ability to track changes to the collections of children in the view. In many ways, this is quite a nebulous subject, as the number of ways in which view collections can be altered is numerous and subtle. Thankfully, Angular 2 provides a solid foundation for tracking these changes.

Note

The code, links, and a live example of this are available at http://ngcookbook.herokuapp.com/4112/.

Getting ready

Suppose you begin with the following skeleton application:

[app/inner.component.ts] import {Component, Input} from '@angular/core'; @Component({ selector: 'inner', template: `<p>{{val}}` }) export class InnerComponent { @Input() val:number; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required