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