I have 4 buttons each with unique value.I am getting undefined in console log with current code.
HTML
<button type="submit" class="parcel-btn weight-option" value="25" (click)="onItemSelector()">
<button type="submit" class="parcel-btn weight-option" value="50" (click)="onItemSelector()">
<button type="submit" class="parcel-btn weight-option" value="250" (click)="onItemSelector()">
<button type="submit" class="parcel-btn weight-option" value="100" (click)="onItemSelector()">
Typescript
onItemSelector() {
const weightSelector = this.elm.nativeElement.querySelectorAll('.weight-option').value;
console.log(weightSelector);
}
Try this
Pass the value to the onItemSelector function
<button type="submit" class="parcel-btn weight-option" (click)="onItemSelector(25)">
Get the value in ts
onItemSelector(value :any) {
console.log(value);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.