2

I'm a newbie with Angular 6.I have a few problems in call method another component. I have 3 components like this

  • app.component.ts
  • com.header.ts
  • app.component-user-profile.ts

In app.component.ts I include com.header.ts

**com.header.html**
<com-header>{{fullName}}</com-header>
**com.header.ts**
private onGetUserInfo(){
   this.fullName = "My FullName"
}
public onTest(){
  this.onGetUserInfo();
}
**app.component-user-profile.html**
<com-header>{{fullName}}</com-header><!--Without Include-->
<button (click)="onTest();">call method form com.header.ts</button>
app.component-user-profile.ts
private onTest(){
   //call method form com.header.ts
    ????
}

How to call method from call method form com.header.ts without include?
<com-header></com-header><!--Without Include-->

Thank you

4
  • Use event emitters or else just initialize components and call to those methods using component objects. Commented Jul 23, 2018 at 2:32
  • I'm sr,i don't understand,have you example ? Commented Jul 23, 2018 at 5:48
  • stackoverflow.com/a/37587862/6284370 you better check this post :) Commented Jul 23, 2018 at 6:44
  • Thank you.I follow this post.But I called to method,but View html not reload data Commented Jul 24, 2018 at 11:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.