angular - Angular2 How can i Use One Component function In Another Component -


here have 2 component cacadingcomponent , logincomponent want consume cacadingcomponent function in logincomponent

cacadingcomponent

export class cascadingcomponent {    countrylist: country[];    constructor(private _cacadeservice: cascadindservice) {           }     getcountry() {         return this._cacadeservice.getcountrylist().subscribe((data) => this.countrylist = data);     } 

logincomponent.ts

here want call getcountry() function in logincomponent

export class logincomponent{ //here how can call } 

    export class logincomponent implements oninit{     @viewchild(cascadingcomponent) cascadingcomponent: cascadingcomponent ;     ngoninit(){     this.cascading.getcountry();} } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -