Advertisement
selvalives

Untitled

Aug 8th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import { Component, OnInit, OnDestroy } from '@angular/core';
  2. import { Observable, Subscription } from 'rxjs';
  3.  
  4. import { DocumentService } from 'src/app/services/document.service';
  5.  
  6. @Component({
  7. selector: 'app-document-list',
  8. templateUrl: './document-list.component.html',
  9. styleUrls: ['./document-list.component.scss']
  10. })
  11. export class DocumentListComponent implements OnInit, OnDestroy {
  12. documents: Observable<string[]>;
  13. currentDoc: string;
  14. private _docSub: Subscription;
  15.  
  16. constructor(private documentService: DocumentService) { }
  17.  
  18. ngOnInit() {
  19. this.documents = this.documentService.documents;
  20. this._docSub = this.documentService.currentDocument.subscribe(doc => this.currentDoc = doc.id);
  21. }
  22.  
  23. ngOnDestroy() {
  24. this._docSub.unsubscribe();
  25. }
  26.  
  27. loadDoc(id: string) {
  28. this.documentService.getDocument(id);
  29. }
  30.  
  31. newDoc() {
  32. this.documentService.newDocument();
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement