Open ahirhasmukh opened 7 years ago
@smartHasmukh @valorkin @Namek @NathanWalker @lzoubek
I am facing same issue like this. 18 hours spend in this issue. any solution?
I think there are 2 issues in your code.
[items]="items"
async
pipe. Something likeitems$ = new EventEmitter<any[]>();
items = [];
addColors() {
// create / update existing array
items.push({...});
items$.next(items);
}
[items]="items$ | async"
I will try it. Thanks
@smartHasmukh do you solve this issues?
Thanks @lzoubek for your answer. Was working on the similar thing and your post helped me to make it work. Greetings to Olomouc from Ostrava!
@wuhemei I will try on monday and will post as well. It will work or not.
for some reason I could not get this to work, it would update the list only once, this answer helped me, and it just works, though it does look more inefficient than having the async pipe. Ah well, Angular noob ;)
I think there are 2 issues in your code.
- in your HTML template you should probably have
[items]="items"
- In order to update ng-select items you cannot just add them into the array that is bound to your template, because this does not trigger a setter on ng-select component. Setter needs to be tiggered, because ng-select internally transforms your items into it's model. see code. So in your (click) code you need to either create new array or you can use EventEmitter together with
async
pipe. Something likeitems$ = new EventEmitter<any[]>(); items = []; addColors() { // create / update existing array items.push({...}); items$.next(items); }
[items]="items$ | async"
Yes,its working well, thanks.
I want to assign data(colors) on click event but It is doesn't work this moment. so please review my code and let me know. how it's work.
==== TYPESCRIPT CODE ====
OR
===== HTML CODE ====
@valorkin @Namek @marcalj @NathanWalker @lzoubek @kfbishop