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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -