I am assigning the below datasource 'tabNameList' on page load. After it loads the select list I then assign it the default value of lets say 12. This should trigger the below code to fire however it never fires. How can I get the code to fire the second the tablist is loaded and the selectedTabId is set to 12?
The setup code
LoadTabNames(){
this._userProfileService.loadTabNames(this.screenId).subscribe(data => {
this.DisableTab= false;
this.tabNameList = data[0];
this.selectedTabId = data[0]["ScreenId"] <----- TabNameChanged event should fire right here since the ngModel has changed
this.cdr.detectChanges();
})
}
TabNameChanged(event){
this.selectedColumns = [];
this.availableColumns = [];
// When the tab select changes load the new headers into the First ListBox
const detailList = filterBy(this.UserProfileTabData, {
logic: 'and',
filters: [
{ field: 'ScreenId', operator: 'eq', value: this.screenId, ignoreCase: true },
{ field: 'TabId', operator: 'eq', value: event, ignoreCase: true }
]
});
detailList.forEach(element => {
this.selectedColumns.push(element["ColumnName"]);
});
}
My html
<div class="col">
<label for="dropdown2">Tab Name</label>
<select #tab class="custom-select custom-select-lg mb-3" id="dropdown2" [disabled]='DisableTab' (ngModelChange)='TabNameChanged($event)' [(ngModel)]="selectedTabId">
<option *ngFor="let tab of tabNameList let i=index" [(ngValue)]="tab.TabId" >{{tab.TabName}}</option>
</select>
</div>