Hello everyone I'd like to send select option data from ngFor to Ts file but I tried [attr.value] , (ngModelChange) (change) all of them sent data's name only I want to send the all data which comes from ngFor
Html
<select [(ngModel)]="event"
class="selectpicker show-menu-arrow form-control show-tick"
data-style="btn-primary" (change)="doSomething(event)">
<option *ngFor="let event of events|filter:search"
EventInput="{{event}}"
[attr.value]="event2">
{{event.eventName}}
</option>
</select>
TS
@Input('EventInput') EventInput: any;
doSomething(event) {
console.log("optValue: ", event);
//this.eventDetailsPageSend(event);
console.log("input: ", this.EventInput);
}
the optValue comes only name of event but I need the all data like id,etc(how comes from ngFor) so that I can push another page.I don't know if i should use Input or ngModelChange for being new with angular and this issue
Thank you.
JSON.stringifyto pass all your object into the value (which I don't recommend), or you use Array methods such asfind,filterorreducein your change function. - user4676340eventsproperty. - user4676340this.events.filter(ev => console.log(ev))and see how you can compare youreventvariable to thisev- user4676340