diff --git a/src/main/angular/src/app/shared/search/search.component.ts b/src/main/angular/src/app/shared/search/search.component.ts index 390a4a2..08cc7e0 100644 --- a/src/main/angular/src/app/shared/search/search.component.ts +++ b/src/main/angular/src/app/shared/search/search.component.ts @@ -11,6 +11,8 @@ export class SearchComponent implements OnInit { private changedTimeout: number | undefined; + private initial_?: number; + @ViewChild('input') input2?: ElementRef; @@ -23,9 +25,6 @@ export class SearchComponent implements OnInit { @Input() searchService!: ISearchService; - @Input() - initial?: number; - @Input() allowEmpty: boolean = true; @@ -42,13 +41,24 @@ export class SearchComponent implements OnInit { cancelOnBlur: boolean = true; + @Input() + set initial(value: number | undefined) { + this.initial_ = value; + if (this.initial) { + this.searchService.searchById(this.initial, result => this.selected = result, _ => _); + } else { + this.selected = undefined; + } + } + + get initial(): number { + return this.initial_; + } + constructor() { } ngOnInit(): void { - if (this.initial) { - this.searchService.searchById(this.initial, result => this.selected = result, _ => _); - } } changed(): void {