English 中文(简体)
选择 Ng 不显示, 无法读取 null 的属性
原标题:Ng Select is not showing, Cannot read Properties of null
I am working with Angular 11 and I have installed ng select module version 6 since the latest one did not work with my current Angular version for this project, and according to their table this is the best fitting version for Angular 11. The problem I am facing is that even after doing the right imports with no errors on app.module nor on the component I am working on, the console throws this error claiming there is a null property: I am just testing with the default example given on their github page but still, no success. Although, I have tried following the same steps on another project (running Angular 15 with the latest version of ng select) and it worked just well. Here is the the HTML code: The .ts of this component: selectedCar: number; cars = [ { id: 1, name: Volvo }, { id: 2, name: Saab }, { id: 3, name: Opel }, { id: 4, name: Audi }, ]; The imports: import { FormsModule } from @angular/forms ; import { NgSelectModule } from @ng-select/ng-select ; import { ReactiveFormsModule } from @angular/forms ; I ve also imported the style file on my styles.scss (the global style file for the project): @import ~@ng-select/ng-select/themes/default.theme.css ; I would appreciate any help to understand the cause of this issue. Thanks in advance.
问题回答
it might be in your APIs data there will be a value which will be null. Please check this one Cannot read property $ngoptionlabel of null when using ng-select




相关问题
Angular matSort not working on Date column by desc

Trying to sort the material table with date column , date format is MM/DD/YYYY ,h:mm A , order of date is not by latest date and time. Anything which i missed from the below stackblitz code. https:/...

热门标签