I have a select - option in angular, and I need to check values that have same id as id in database, so I have tried something like this:
isDropdownValueSelected(amf: ApplicationModuleForm): boolean {
for (let i = 0; i < this.role.applicationForms.length; i++) {
if (this.role.applicationForms[i].id == amf.id) {
return true;
}
else {
return false;
}
}
}
My angular part:
<div class="col-lg-9">
<select id="applicationModuleFormSelect" name="applicationModuleFormSelect" class="form-control multiselect-select-all" multiple="multiple" data-fouc>
<option *ngFor="let amf of appModuleForms;" [value]="amf.id" [selected]="isDropdownValueSelected(amf)">{{amf.title}}</option>
</select>
</div>
So basically there I wanted to loop for each id in option and if I found similar in my array I would return true, because array this.role.applicationForms
holds values from database, but unfortunatelly this does not works, nothing is selected in dropdown and I tested with console log it says only 1 value exist even if there are 3..
Thanks guys Cheers