Skip to content

Instantly share code, notes, and snippets.

@t-palmer
Created March 9, 2019 03:18
Show Gist options
  • Save t-palmer/36309e5233ea11cd445c38fce92e4876 to your computer and use it in GitHub Desktop.
Save t-palmer/36309e5233ea11cd445c38fce92e4876 to your computer and use it in GitHub Desktop.
Example parent component for viewchild-unit-test-example
import { Component, ViewChild } from '@angular/core';
import { ChildComponent } from '../child/child.component';
@Component({
selector: 'app-parent',
template: `
<button type="button" (click)="update()">Update</button>
<br>
<app-child></app-child>`
})
export class ParentComponent {
@ViewChild(ChildComponent) childComponent: ChildComponent;
update() {
this.childComponent.updateTimeStamp();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment