I am working in an Angular 4 project ,In this I need to get the value which is in the Span tag on Onclick of an Image .
I referred some Stackoverflow qustions but nothing is worked for me ...
This is my HTML.
<div class="col-sm-4">
<div class="card">
<div class="card-img-top card-img-top-250 one">
<img class="img-fluid" "src="assets/Images/Popular_Products/3.jpg" alt="img1">
<img routerLink="/my-cart" class="img-fluid two" src="assets/Images/Popular_Products/10.jpg" alt="img2" onclick="getProductName()" >
</div>
<div class="card-block pt-2">
<div class="col-sm-12 text-center card-text">
<span #Pname> iPhone</span>
<br>
<br>
1500 $
</div>
</div>
</div>
</div>
This is my .ts file
getProductName(Pname: string) {
this.http.get(`http://localhost:57036/api/data/CartCount/?ProductName=${Pname}`)
.subscribe(data => this.res = (data['ITEM_QTY']),
error => console.error(error));
}
When I clicked on the image ,I want to get the value in the span tag and pass it to the API ,but in my case I can't get the span value . I am new to Angular4 please guide me to solve this .