我已经定义了一个函数selectCountry,我想在div * ngFor中定义的click事件上调用它。
问题是,仅当我单击任何显示的标签时,才第一次调用该函数,之后它显示未定义的函数。
HTML:
<div>
<label>AutoComplete Package: </label>
<input autocomplete [config]="config" [items]="countries"
(selectEvent)="onSelect($event)">
</div>
<div>
<label>Manual: </label>
<input [(ngModel)]="searchInput" (keyup)="onInputChange()">
<div class='searchResultList padding' *ngFor='let country of
countries' [ngClass]="{ 'active' : selectedCountry == country.id}">
<label (click)='selectCountry(country)'>
{{ country.country }}
</label>
</div>
</div>