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/counter/counter.component.ts

    rd2e69be ref1219a  
    1 import { Component, Inject } from '@angular/core';
     1import { Component, OnInit, ViewChild, Inject } from '@angular/core';
    22import { HttpClient } from '@angular/common/http';
    33import { HealthFacilities } from '../models/HealthFacilities';
     4import { MatTableDataSource } from '@angular/material/table';
     5import { MatPaginator } from '@angular/material/paginator';
     6import { MatSort } from '@angular/material/sort';
     7
    48@Component({
    59  selector: 'app-counter-component',
     
    711  styleUrls: ['./counter.component.css']
    812})
    9 export class CounterComponent {
     13export class CounterComponent implements OnInit {
    1014  public facilities: HealthFacilities[];
     15  displayedColumns = ['Име','Општина','Адреса', 'Тип', 'Е-пошта', 'Телефон'];
     16  dataSource = new MatTableDataSource<HealthFacilities>();
     17
     18  @ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
     19  @ViewChild(MatSort) sort: MatSort;
    1120
    1221  constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
     
    1423      this.facilities = result;
    1524      console.log(this.facilities);
     25      this.dataSource = new MatTableDataSource<HealthFacilities>(this.facilities);
    1626    }, error => console.error(error));
    1727  }
     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  }
    1841}
    19 /*interface healthFacilities {
    20   Name: string;
    21   Municipality: string;
    22   Address: string;
    23   Type: string;
    24   Email: string;
    25   Phone: string;
    26 }*/
    27 
Note: See TracChangeset for help on using the changeset viewer.