-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't add more item if destination array is pre-defined #120
Comments
The problem occurs only if source and destination are array of objects. With array of strings it works as expected. |
Without seeing the source for your custom-listbox and the arrays of objects, it is impossible for me to guess the cause. Can you create a small reproducer in stackblitz of the problem you are having? I am not seeing it in the demo, which uses arrays of objects. |
Same issue here. I'm using Angular 8. |
@renanvm - could you provide a small code sample that reproduces the error? |
`export class DistribuidorRegiaoComponent implements OnInit { regioes: any[] = []; ngOnInit() { It loads just the first item of the array |
@renanvm - in your example, what is an example of res.body? |
|
@renanvm: Please change your template to be: <dual-list key="id" display="nome"
[source]="regioes" [height]="'300px'" [format]="format" [(destination)]="regioesSelecionadas"></dual-list> Here is the code I used for the component: import { Component, OnInit } from '@angular/core';
import { DualListComponent } from 'angular-dual-listbox';
import { RegiaoService } from './regiao.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit{
format: any = DualListComponent.DEFAULT_FORMAT;
regioes: any[] = [];
regioesSelecionadas: any[] = [];
constructor(private regiaoService: RegiaoService) {
}
ngOnInit() {
this.regiaoService.query().subscribe(res => {
this.regioes = res;
});
}
} Here's what I used for the service: import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable, of } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class RegiaoService {
private regiao: any[] = [
{id: 1051, nome: "Norte", distribuidor: null},
{id: 1052, nome: "Sul", distribuidor: null}
];
private regiaoSubj: BehaviorSubject<any>;
constructor() {
this.regiaoSubj = new BehaviorSubject<any>(this.regiao);
}
query(): Observable<any> {
return this.regiaoSubj.asObservable();
}
} I'm not seeing any errors and I see Norte and Sul available to select. Either this is not the same issue @harishajdarevic saw or the reproducer is not complete enough for your use case to replicate the error or it was a simple misconfiguration not providing the |
Thanks @czeckd . Now everything is working. Really was a misconfiguration. |
What is happening is that it doesn't work if destination array is already predefined.
If I set destination array as predefined and then try to add more items I'm getting the error:
The text was updated successfully, but these errors were encountered: