Add routing(id) vers page Details
This commit is contained in:
		
							parent
							
								
									f1d0af652b
								
							
						
					
					
						commit
						b81ebb7d89
					
				
					 4 changed files with 28 additions and 11 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| <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" | ||||
|             [iconName]="'heart'" | ||||
|             [iconColor]="'#e35d6a'" | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||||
| import { Router } from '@angular/router'; | ||||
| 
 | ||||
| 
 | ||||
| @Component({ | ||||
|  | @ -9,14 +10,21 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | |||
| export class CardPlanteComponent implements OnInit { | ||||
|   @Input() plant: any; | ||||
|   @Output() clickLike = new EventEmitter(); | ||||
|   constructor() { } | ||||
|   @Output() clickCardId = new EventEmitter(); | ||||
| 
 | ||||
|   constructor(private router : Router) {} | ||||
| 
 | ||||
|   ngOnInit(): void { | ||||
|   } | ||||
| 
 | ||||
|   onClickLike() { | ||||
|     console.log('click'); | ||||
|     this.clickLike.emit(); | ||||
|   } | ||||
| 
 | ||||
|   onGetId(id : string){ | ||||
|     this.clickCardId.emit(id); | ||||
|     this.router.navigateByUrl('/details/'+ id); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //http://localhost:3000/list_products?product_id=952438
 | ||||
|  |  | |||
|  | @ -1 +1,3 @@ | |||
| <p>page-details works!</p> | ||||
| <p (clickCardId) = "test($event)"></p> | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| import { Component, OnInit } from '@angular/core'; | ||||
| 
 | ||||
| 
 | ||||
| @Component({ | ||||
|   selector: 'app-page-details', | ||||
|   templateUrl: './page-details.component.html', | ||||
|  | @ -7,9 +8,15 @@ import { Component, OnInit } from '@angular/core'; | |||
| }) | ||||
| export class PageDetailsComponent implements OnInit { | ||||
| 
 | ||||
|   constructor() { } | ||||
| 
 | ||||
|   ngOnInit(): void { | ||||
|  detailsPlant: any | ||||
|   constructor() { | ||||
|    } | ||||
| 
 | ||||
|   ngOnInit(): void { | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   test(texte:any){ | ||||
|   console.log(texte); | ||||
|   } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Romain
						Romain