source: Farmatiko/ClientApp/src/app/counter/counter.component.ts@ ef1219a

Last change on this file since ef1219a was ef1219a, checked in by Mile Jankuloski <mile.jankuloski@…>, 2 years ago

Handled REST API calls, searchbars and paginators implemented, overall frontend improvment

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import { Component, OnInit, ViewChild, Inject } from '@angular/core';
2import { HttpClient } from '@angular/common/http';
3import { HealthFacilities } from '../models/HealthFacilities';
4import { MatTableDataSource } from '@angular/material/table';
5import { MatPaginator } from '@angular/material/paginator';
6import { MatSort } from '@angular/material/sort';
7
8@Component({
9 selector: 'app-counter-component',
10 templateUrl: './counter.component.html',
11 styleUrls: ['./counter.component.css']
12})
13export class CounterComponent implements OnInit {
14 public facilities: HealthFacilities[];
15 displayedColumns = ['Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
16 dataSource = new MatTableDataSource<HealthFacilities>();
17
18 @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
19 @ViewChild(MatSort) sort: MatSort;
20
21 constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
22 http.get<HealthFacilities[]>(baseUrl + 'HealthFacilities/Get?').subscribe(result => {
23 this.facilities = result;
24 console.log(this.facilities);
25 this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities);
26 }, error => console.error(error));
27 }
28 ngOnInit(): void {
29 }
30
31 ngAfterViewInit(): void {
32 this.dataSource.paginator = this.paginator;
33 this.dataSource.sort = this.sort;
34 }
35
36 applyFilter(filterValue: string) {
37 filterValue = filterValue.trim();
38 filterValue = filterValue.toLowerCase();
39 this.dataSource.filter = filterValue;
40 }
41}
Note: See TracBrowser for help on using the repository browser.