1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-contact-detail',
templateUrl: './contact-detail.component.html',
styleUrls: ['./contact-detail.component.css']
})
export class ContactDetailComponent implements OnInit {
contact = {};
constructor(private route: ActivatedRoute, private http: HttpClient) { }
ngOnInit() {
this.getContactDetail(this.route.snapshot.params['id']);
}
getContactDetail(id) {
this.http.get('/contacts/'+id).subscribe(data => {
this.contact = data;
});
}
} |