Topic: mdb-material-chips remove spaces
Hi,
I'm using mdb-material-chips component and I need to handle the "new item adding" event, because I need to remove any spaces from the new tag.
How can I do it?
thanks
Marco
Damian Gemza staff answered 5 years ago
Dear @bitjuice
I don't know, what you want to do exactly. Do you want to remove spaces from chip before adding them to an array or something else?
You can use the (labelsChange)
which is fired, when an array of chips has changed, and then do whatever you want.
Please take a look at the below code:
.html:
<mdb-material-chips [(ngModel)]="addtags" (labelsChange)="onLabelsChange($event)" (keydown.enter)="onEnterKeyDown($event)"></mdb-material-chips>
.ts:
hideElement: boolean = true;
addtags: string[] = [];
onLabelsChange(event: any) {
console.log(event);
}
onEnterKeyDown(event: any) {
event.target.value = event.target.value.trim().replace(' ', '-');
}
Best Regards,
Damian
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: 8.0.0
- Device: PC
- Browser: Chorme
- OS: Windows 10
- Provided sample code: No
- Provided link: No