Fix select initialization.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<label for="service-type">Type</label>
|
||||
<app-select [options]="serviceTypes"
|
||||
optionLabel="label"
|
||||
[value]="application?.serviceType"
|
||||
(onSelection)="onServiceTypeSelection($event)"></app-select>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
|
||||
@@ -50,7 +50,7 @@ export class UpdateApplicationComponent implements OnInit {
|
||||
const appToUpdate = { ...this.application } as Application;
|
||||
appToUpdate.name = this.form.controls.name.value;
|
||||
appToUpdate.serviceName = this.form.controls.serviceName.value;
|
||||
// appToUpdate.serviceType = this.form.controls.serviceType.value;
|
||||
appToUpdate.serviceType = this.form.controls.serviceType.value;
|
||||
appToUpdate.image = this.form.controls.image.value;
|
||||
|
||||
this._applicationService.update(appToUpdate)
|
||||
|
||||
@@ -19,6 +19,7 @@ export class SelectComponent implements OnChanges {
|
||||
@Input() formControl: any;
|
||||
@Input() options?: any[];
|
||||
@Input() optionLabel?: string;
|
||||
@Input() value?: any;
|
||||
@ViewChild('select', {static: true}) select?: ElementRef;
|
||||
@ViewChild('selectIcon', {static: true}) selectIcon?: ElementRef;
|
||||
@Output() onSelection: EventEmitter<any> = new EventEmitter();
|
||||
@@ -33,6 +34,11 @@ export class SelectComponent implements OnChanges {
|
||||
value: option,
|
||||
label: typeof this.optionLabel === 'undefined' ? undefined : option[this.optionLabel]
|
||||
} as Option));
|
||||
|
||||
const selectedOption = this._options.find(option => option.value === this.value || option.value?.value === this.value);
|
||||
if (selectedOption) {
|
||||
this.setOption(selectedOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user