How do I send 'countryCode.Display' value with updateCountryCode() call.
<div >
<button type="button" data-toggle="dropdown">{{ SelectedCountryCode }}</button>
<ul >
<li *ngFor="let countryCode of AllEuCountryCodeValues"><a (click)="updateCountryCode('countryCode.Display')">{{countryCode.Display}}</a></li>
</ul>
</div>
CodePudding user response:
You just need to pass the reference to the object in, not a string.
<li *ngFor="let countryCode of AllEuCountryCodeValues">
<a (click)="updateCountryCode(countryCode.Display)">{{countryCode.Display}}</a>
</li>
updateCountryCode(countryCode.Display)
vs updateCountryCode('countryCode.Display')
, the second option passes a string, the first one whatever the value of the object is.