Hey guys i assigned the id to each bootstrap card and when i render it in html component it gets correctly rendered but how do i retreive it in the console? means on clicking the "Add to Cart" button i want to pass it to the .component.ts file ..How do i do that?
html component
<div class=" row justify-content-md-center">
<div class="col-md-3 describe" *ngFor="let p of filteredproducts
;let i=index"> ///here i assigned the id
<mdb-card class="mdb">
<mdb-card-img src="{{p.imageurl}}" alt="Card image cap"></mdb-card-
img>
<mdb-card-body>
<mdb-card-title>
<h4>{{p.title}}</h4>
</mdb-card-title>
<mdb-card-text> {{p.price}}
</mdb-card-text>
<div>
<div *ngIf="counter==0">
<button class="button" id="btn" (click)="onclick()" åmdbBtn
type="button" color="primary" block="true" mdbWavesEffect>Add to
Cart</button>
</div>
<div *ngIf="counter>0">
</div>
</div>
</mdb-card-body>
</ mdb-card> </div>
</div>
.component.ts file
export class HomeComponent implements OnInit {
counter=0
constructor(private route:ActivatedRoute,private
router:Router,private prservice:Productservice) {
ngOnInit() {
}
onclick(){
this.counter++
console.log(this.counter)
}
}
here i need to retreive the id