7
親クラスから子コンポーネントメソッドを呼び出す-Angular
呼び出したいメソッドを持つ子コンポーネントを作成しました。 このメソッドを呼び出すと、console.log()行が起動されるだけで、testプロパティは設定されませんか? 以下は、変更を加えたAngularアプリのクイックスタートです。 親 import { Component } from '@angular/core'; import { NotifyComponent } from './notify.component'; @Component({ selector: 'my-app', template: ` <button (click)="submit()">Call Child Component Method</button> ` }) export class AppComponent { private notify: NotifyComponent; constructor() { this.notify = new NotifyComponent(); } submit(): void { // execute child component method …