I need to have ngModel in chip component because my list is updated from backend and accordingly I want to remove/add chips on UI. So basically every time my list is updated the chip component should show the items which are there in that list.
2 Answers, 1 is accepted
0
Accepted
Georgi
Telerik team
answered on 01 Jul 2020, 09:15 AM
Hello Maitri,
I assume you receive a list (array) of items from your backend? If that's the case, a simple chip component as it is, won't do the trick because it represents a single piece of info and not a list. You could make your own chip-list component and use that to display and change the said list of items.
Another alternative could be to use the multiselect as I think it does a similar thing to what I think you're trying to achieve.
You don't necessarily need to use [(ngModel)] in order to display the data. An alternative would be to equip your chip-list component with an @Output, and emit events which then update the value in your parent component. And eventually send those back to your backend.
However if you have other reasons for requiring the ngModel directive, then you need to implement the ControlValueAccessor interface in your child component. Here is a working demo.
Hope that answers your question. Please let me know if I can help you any further.
Regards,
Georgi
Progress Telerik
Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic. Our thoughts here at Progress are with those affected by the outbreak.