Affichage en tableau de la liste des DZs
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { Component, OnInit, Injectable } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
|
||||
import { DropZoneResp } from '../../models/dropzone';
|
||||
import { ServiceApi } from '../../services/serviceApi';
|
||||
@@ -13,6 +15,9 @@ import { ServiceComm } from '../../services/serviceComm';
|
||||
|
||||
export class ListOfDzsComponent implements OnInit {
|
||||
public listOfDropZones: Array<DropZoneResp> = new Array<DropZoneResp>();
|
||||
public displayedColumns: Array<string> = ['id', 'name'];
|
||||
public dataSourceTable = new MatTableDataSource<DropZoneResp>();
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
|
||||
constructor(private serviceApi: ServiceApi,
|
||||
private serviceComm: ServiceComm) {
|
||||
@@ -25,6 +30,10 @@ export class ListOfDzsComponent implements OnInit {
|
||||
|
||||
getListOfDropZones() {
|
||||
this.serviceApi.getListOfDropZones()
|
||||
.subscribe(data => this.listOfDropZones = data);
|
||||
.subscribe(data => {
|
||||
this.listOfDropZones = data;
|
||||
this.dataSourceTable = new MatTableDataSource<DropZoneResp>(data);
|
||||
this.dataSourceTable.paginator = this.paginator;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user