Ignore:
Timestamp:
07/27/20 23:36:14 (2 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
e42f61a
Parents:
d2e69be
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/home/home.component.ts

    rd2e69be ref1219a  
    1 import { Component, OnInit, Input, ViewChild } from '@angular/core';
     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
    28
    39@Component({
     
    612  styleUrls: ['./home.component.css']
    713})
    8 export class HomeComponent {
     14export class HomeComponent implements OnInit {
     15  public facilities: HealthFacilities[];
     16  displayedColumns = ['Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
     17  dataSource = new MatTableDataSource<HealthFacilities>();
     18
     19  @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
     20  @ViewChild(MatSort) sort: MatSort;
     21
     22  constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
     23    http.get<HealthFacilities[]>(baseUrl + 'HealthFacilities/Get?').subscribe(result => {
     24      this.facilities = result;
     25      console.log(this.facilities);
     26      this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities);
     27    }, error => console.error(error));
     28  }
     29  ngOnInit(): void {
     30  }
     31
     32  ngAfterViewInit(): void {
     33    this.dataSource.paginator = this.paginator;
     34    this.dataSource.sort = this.sort;
     35  }
     36
     37  applyFilter(filterValue: string) {
     38    filterValue = filterValue.trim();
     39    filterValue = filterValue.toLowerCase();
     40    this.dataSource.filter = filterValue;
     41  }
    942}
Note: See TracChangeset for help on using the changeset viewer.