3
では一つのコンポーネント機能を使用することができ、ここで私は2コンポーネントと同様CacadingComponentそしてLoginComponent私はLoginComponentAngular2どのように私は別のコンポーネント
にCacadingComponent機能を消費したくありCacadingComponent
export class CascadingComponent {
CountryList: Country[];
constructor(private _CacadeService: CascadindService) {
}
GetCountry() {
return this._CacadeService.GetCountryList().subscribe((data) => this.CountryList = data);
}
LoginComponent.ts
ここで私はLoginComponentでGetCountry()関数を呼びたいと思っています
下図のようにあなたは、クラスCascadingComponent
のオブジェクトを作成することにより、メソッドにアクセスすることができます
export class LoginComponent{
//Here How can I call
}
共有機能を持っているしたい場合は、サービスを利用することができ、など また、あなたが使用する可能性がありますコンポーネントのビュー内のコンポーネント –
はい@Dawidでも要件は異なる –