child parent communication best practices in Angular

前端 未结 4 933
天命终不由人
天命终不由人 2021-01-05 22:25

I\'m trying to become better at Angular and I want to know the best practices between child-parent communication. My current app I want to work on is on Angular 6. I know I

4条回答
  •  醉梦人生
    2021-01-05 23:24

    You can subject to Share Data between multiple Component

    Create Service

     import { Injectable } from '@angular/core';
        import {Subject} from 'rxjs/Subject';    
        @Injectable()
        export class ChildParentService {
    
         data=new Subject();
          constructor() { }
    
        }
    

    Example:https://stackblitz.com/edit/child-to-parent-bntt2h

提交回复
热议问题