création tableau et récupération des données
This commit is contained in:
parent
4bbf8906e8
commit
d25efc4f73
4 changed files with 343 additions and 5 deletions
|
@ -1 +1,29 @@
|
||||||
<p>page-tableau works!</p>
|
<table class="table">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Id</th>
|
||||||
|
<th scope="col">Nom</th>
|
||||||
|
<th scope="col">Prix</th>
|
||||||
|
<th scope="col">Quantité</th>
|
||||||
|
<th scope="col">En stock</th>
|
||||||
|
<th scope="col">Catégorie</th>
|
||||||
|
<th scope="col">Note</th>
|
||||||
|
<th scope="col">Modifier</th>
|
||||||
|
<th scope="col">Supprimer</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let products of listData">
|
||||||
|
<th scope="row">{{products.product_id}}</th>
|
||||||
|
<td>{{products.product_name}}</td>
|
||||||
|
<td>{{products.product_price}}</td>
|
||||||
|
<td>{{products.product_qty}}</td>
|
||||||
|
<td>{{products.product_instock}}</td>
|
||||||
|
<td>{{products.product_breadcrumb_label}}</td>
|
||||||
|
<td>{{products.product_rating}}</td>
|
||||||
|
<td><a class="bi-pencil-square" routerLink="../modifier"></a></td>
|
||||||
|
<td class="bi-trash-fill" style="color: red; cursor: pointer;" (click)="onClickDelete(products.product_id)"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { AdminService } from '../../services/admin.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-tableau',
|
selector: 'app-page-tableau',
|
||||||
|
@ -6,10 +7,21 @@ import { Component, OnInit } from '@angular/core';
|
||||||
styleUrls: ['./page-tableau.component.scss']
|
styleUrls: ['./page-tableau.component.scss']
|
||||||
})
|
})
|
||||||
export class PageTableauComponent implements OnInit {
|
export class PageTableauComponent implements OnInit {
|
||||||
|
public listData!: any[];
|
||||||
constructor() { }
|
constructor(private adminService: AdminService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.listData = [];
|
||||||
|
this.adminService.getData().subscribe(
|
||||||
|
(listPlant: any[]) => {
|
||||||
|
this.listData = listPlant;
|
||||||
|
this.listData.length = 9;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onClickDelete(id: number){
|
||||||
|
console.log(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AdminService {
|
export class AdminService {
|
||||||
|
apiUrl: string;
|
||||||
|
|
||||||
constructor() { }
|
constructor(private httpClient: HttpClient) {
|
||||||
|
this.apiUrl = environment.apiUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
getData(): Observable<any[]> {
|
||||||
|
return this.httpClient.get<any[]>(`${this.apiUrl}/list_products`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue