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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -