contact.service.ts 897 Bytes
Newer Older
1
import { HttpClient } from '@angular/common/http';
2
import { Injectable } from '@angular/core';
Your Name committed
3
import { Observable } from 'rxjs';
4
import { Contact } from "../models/contact.model";
5 6 7

@Injectable({ providedIn: 'root' })
export class ContactService {
8 9

    constructor(private http: HttpClient) { }
10
    url: string = "http://2839-110-169-220-190.ngrok.io";
Your Name committed
11
    listContact: Contact[] = []
12

13 14
    addContact(model: Contact) {
        this.listContact.push(model);
15
        this.listContact.reverse
16
    }
17

Your Name committed
18 19 20 21 22 23
    updateContact(model: Contact) {
        this.http.put(this.url + "/contact/" +model.id, model).subscribe(response => {
          console.log(response);
          alert("อัพเดทข้อมูลการติดต่อสำเร็จ")
        })
      }
Chanachai committed
24

Your Name committed
25 26
    getListContact(): Observable<Contact[]> {
        return this.http.get<Contact[]>(this.url + "/contact/lists");
27
    }
GAME\parin committed
28
}