Angular2 call method of other component

前端 未结 4 1801
故里飘歌
故里飘歌 2020-12-14 11:35

I have an Angular2 app in which I created an Header component, that\'s rendered in my main App component.

Now, I have an other Form component that should have its su

4条回答
  •  囚心锁ツ
    2020-12-14 12:28

    The use of services and subjects is the easiest way. If you want to keep a record of your data, you can even use replay subject

    private notify: ReplaySubject = new ReplaySubject();
    

    But, you can even try out a library called as eventbus. I have ran into same issues and eventbus is just the right answer for this.

提交回复
热议问题