paper.component.ts (828B)
1 import {Component, OnInit, ViewEncapsulation} from '@angular/core'; 2 import {ActivatedRoute} from '@angular/router'; 3 import {ApiService, Paper} from '../api.service'; 4 5 @Component({ 6 selector: 'app-paper', 7 templateUrl: './paper.component.html', 8 styleUrls: ['./paper.component.scss'], 9 encapsulation: ViewEncapsulation.None 10 }) 11 export class PaperComponent implements OnInit { 12 uuid: string; 13 data: Paper; 14 15 constructor(private route: ActivatedRoute, private apiService: ApiService) { 16 this.uuid = this.route.snapshot.params.paperUUID; 17 } 18 19 ngOnInit() { this.getPaper(this.uuid); } 20 21 getPaper(uuid: string) { 22 this.apiService.getPaper(uuid) 23 .subscribe( 24 data => { this.data = data; }, 25 err => console.error('API ERR: ', err), 26 () => console.log('done loading Paper Data') 27 ); 28 } 29 30 }