Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. @Injectable({providedIn: 'root'})
  2. export class ComponentService {
  3. private subject = new Subject<any>();
  4.  
  5. sendData(data: any) {
  6. this.subject.next(data);
  7. }
  8.  
  9. getData(): any {
  10. return this.subject.asObservable();
  11. }
  12. }
  13.  
  14. this.componentService.sendData(element);
  15.  
  16. constructor(private componentService: ComponentService) {
  17. }
  18.  
  19. ngOnInit() {
  20. this.componentService.getData().subscribe(data => data);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement