Created
June 30, 2018 23:17
-
-
Save zkkmin/a1fa1db2ae9bd8e7795d20d7d0a8fb4d to your computer and use it in GitHub Desktop.
Calling child component's function from parent view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, ViewChild } from '@angular/core'; | |
import { RandomQuoteComponent } from './random-quote/random-quote.component' | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
@ViewChild(RandomQuoteComponent) | |
private randomQuoteComponent: RandomQuoteComponent; | |
title = 'Muse'; | |
onClickMe() { | |
this.randomQuoteComponent.getQuote(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment