nebular
nebular copied to clipboard
NbSelect issue when using it with a template variable
Issue type
**I'm submitting a:
- [x] bug report
- [ ] feature request
Issue description
Current behavior:
When using the select component together with a template variable is causes and infinite loop on change detection if we try to access the selected
value
Expected behavior: The component should work as expected and return undefined or null if no value is selected
Steps to reproduce:
<nb-select #values fullWidth placeholder="Select Import Type">
<nb-option value=1>First</nb-option>
<nb-option value=2>Second</nb-option>
</nb-select>
<p *ngIf="values.selected === 1">First Value Selected</p>
Related code:
After looking at the source code I found out that select component tries do access selectionModel array while it is still undefined due to data loading.
As a workarround we can do something like:
<p *ngIf="values && values.selectionModel.length && values.selected === 1">First Value Selected</p>
Other information:
npm, node, OS, Browser
Node: v18.16.0
npm: 9.5.1
Angular, Nebular
nebular: 11.0.0
angular: 15.2.8