view child of child angular code example
Example: view child in angular
content_copy
import {Component, Directive, Input, ViewChild} from '@angular/core';
@Directive({selector: 'pane'})
export class Pane {
@Input() id!: string;
}
@Component({
selector: 'example-app',
template: `
Selected: {{selectedPane}}
`,
})
export class ViewChildComp {
@ViewChild(Pane)
set pane(v: Pane) {
setTimeout(() => {
this.selectedPane = v.id;
}, 0);
}
selectedPane: string = '';
shouldShow = true;
toggle() {
this.shouldShow = !this.shouldShow;
}
}