IvanBodnar
9/9/2018 - 9:23 PM

Angular Services

Angular Services

import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {CardModel} from '../card.model';

@Injectable({
  providedIn: 'root'
})
export class DataService {
  url = 'http://localhost:3000';

  constructor(
    private http: HttpClient
  ) { }

  getCards(): Observable<CardModel[]> {
    return this.http.get<CardModel[]>(this.url);
  }
}