<ion-list>
<ion-item-group *ngFor="let group of groupedContacts">
<ion-item-divider color="light">{{group.letter}}</ion-item-divider>
<ion-item *ngFor="let contact of group.contacts" class="contactlist" style="clear: both;">
<ion-col>
<a start no-padding no-margin>{{contact.name}}</a>
<p start no-padding no-margin>{{contact.number}}</p>
</ion-col>
<ion-label>
<ion-button end float-right round>Tag</ion-button>
</ion-label>
</ion-item>
</ion-item-group>
</ion-list>
The code above is what I use to list my contacts.
My goal is to have the button in that ion-item within the ion-label to, when pressed, get the contact.name
and contact.number
of that item.
How can I do that?
EDIT: This will be a function called by the button in the .ts file
try
<ion-item *ngFor="let contact of group.contacts" ...>
...
<ion-button (click)="processContact(contact)">Click</ion-button>
</ion-item-group>
and in .ts code add function
public processContact(contact) {
console.log(contact.name, contact.number);
}
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.