Add routing(id) vers page Details

This commit is contained in:
Romain 2022-01-11 17:38:35 +01:00
parent f1d0af652b
commit b81ebb7d89
4 changed files with 28 additions and 11 deletions

View File

@ -1,7 +1,7 @@
<div class="plant card mb-4" style="width: 14rem;"> <div class="plant card mb-4" style="width: 14rem;" (click) = "onGetId(plant.product_id)">
<app-icon class="like" <app-icon class="like"
[iconName]="'heart'" [iconName]="'heart'"
[iconColor]="'#e35d6a'" [iconColor]="'#e35d6a'"
(click)="onClickLike()"></app-icon> (click)="onClickLike()"></app-icon>
<img src="{{plant.product_url_picture}}" class="card-img-top" alt="Image de {{ plant.product_name }}"> <img src="{{plant.product_url_picture}}" class="card-img-top" alt="Image de {{ plant.product_name }}">
<div class="card-body"> <div class="card-body">
@ -9,7 +9,7 @@
<div class="card-content"> <div class="card-content">
<app-avis-bar></app-avis-bar> <app-avis-bar></app-avis-bar>
</div> </div>
<div class="d-flex flex-row align-items-end justify-content-between"> <div class="d-flex flex-row align-items-end justify-content-between">
<div class="card-content"> <div class="card-content">
{{ plant.product_unitprice_ati }} € {{ plant.product_unitprice_ati }} €
@ -17,4 +17,4 @@
<a href="#" class="btn btn-success">Pour moi !</a> <a href="#" class="btn btn-success">Pour moi !</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';
@Component({ @Component({
@ -9,14 +10,21 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
export class CardPlanteComponent implements OnInit { export class CardPlanteComponent implements OnInit {
@Input() plant: any; @Input() plant: any;
@Output() clickLike = new EventEmitter(); @Output() clickLike = new EventEmitter();
constructor() { } @Output() clickCardId = new EventEmitter();
constructor(private router : Router) {}
ngOnInit(): void { ngOnInit(): void {
} }
onClickLike() { onClickLike() {
console.log('click'); console.log('click');
this.clickLike.emit(); this.clickLike.emit();
} }
onGetId(id : string){
this.clickCardId.emit(id);
this.router.navigateByUrl('/details/'+ id);
}
} }
//http://localhost:3000/list_products?product_id=952438

View File

@ -1 +1,3 @@
<p>page-details works!</p> <p (clickCardId) = "test($event)"></p>

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-page-details', selector: 'app-page-details',
templateUrl: './page-details.component.html', templateUrl: './page-details.component.html',
@ -7,9 +8,15 @@ import { Component, OnInit } from '@angular/core';
}) })
export class PageDetailsComponent implements OnInit { export class PageDetailsComponent implements OnInit {
constructor() { } detailsPlant: any
constructor() {
}
ngOnInit(): void { ngOnInit(): void {
} }
test(texte:any){
console.log(texte);
}
} }