The displayed value of the nb-select component is not up to date.
- Linguagem predominante
- TypeScript
- Estrelas
- 8.1k
- Forks
- 1.5k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
### Issue type
**I'm submitting a ...** (check one with "x")
* [x] bug report
* [ ] feature request
### Issue description
Refreshing the options of the nb-select component
**Current behavior:**
The selected element is not updated, however the "ngModel" or "selected" corresponds to the element.
**Expected behavior:**
The value of the select displayed corresponds to the selected value.
**Steps to reproduce:**
Update the value containing the options of the nb-select. The option array must not have the same object reference.
**Related code:**
```
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.scss']
})
export class TestComponent implements OnInit {
public selected = { key: 1 };
public defaultOptions = [];
public options1 = [
{ key: 1, label: 'Key 1 selected' },
{ key: 2, label: 'Key 2 selected' },
{ key: 3, label: 'Key 3 selected' },
{ key: 4, label: 'Key 4 selected' },
{ key: 5, label: 'Key 5 selected' }
];
public options2 = [
{ key: 6, label: 'Key 6 selected' },
{ key: 7, label: 'Key 7 selected' },
{ key: 8, label: 'Key 8 selected' },
{ key: 9, label: 'Key 9 selected' },
{ key: 10, label: 'Key 10 selected' }
];
public i = 0;
constructor() {}
ngOnInit() {
setInterval(() => {
if (this.isOdd(this.i)) {
this.defaultOptions = this.options1;
} else {
this.defaultOptions = this.options2;
}
this.i++;
}, 2000);
}
isOdd(num: number) {
return num % 2;
}
}
```
> test.component.ts
```
{{column.label}}
{{column.label}}
{{column.label}}
Selected Key = {{selected.key}}
{{defaultOptions | json}}
```
> test.component.html
### Other information:
In the example above the select HTML 5 is well updated compared to the nb-select (with ngModel or selected)
**npm, node, OS, Browser**
```
```
**Angular, Nebular**
```
```
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.