How to create behavior subject for object and subscribe to it on another component?

后端 未结 2 602

I have created a behaviour subject in a service class.

    public personObject: BehaviorSubject = new BehaviorSubject({
                        


        
2条回答
  •  [愿得一人]
    2020-12-31 21:59

    I forgot to mention that I was using I was using ViewContainerRef to create a sibling component and it turns out behavior subject does not work the same way with component created using ViewContainerRef.

    Other wise Behaviour subjects of any object work exactly like with number or string. I used @Input to send data to component for now.

提交回复
热议问题