bstlboard-front/src/app/pages/entry/entry.page.ts

38 lines
826 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { EntriesService } from '../../services/entries.service';
@Component({
selector: 'page-entry',
templateUrl: './entry.page.html'
})
export class PageEntry implements OnInit {
id: number;
entry: any;
notfound: boolean = false;
boundRefresh: Function;
constructor(private entriesService: EntriesService,
private route: ActivatedRoute) { }
ngOnInit(): void {
this.id = +this.route.snapshot.paramMap.get('id');
this.boundRefresh = this.refresh.bind(this);
this.refresh();
}
refresh() {
this.entriesService.getEntry(this.id).subscribe((data) => {
this.entry = data;
}, (error) => {
if (error.status == 404) {
this.notfound = true;
}
})
}
}