Topic: mdb-material-chips remove spaces

bitjuice pro asked 3 years ago


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?



Damian Gemza staff answered 3 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:


<mdb-material-chips [(ngModel)]="addtags" (labelsChange)="onLabelsChange($event)" (keydown.enter)="onEnterKeyDown($event)"></mdb-material-chips>


 hideElement: boolean = true;
  addtags: string[] = [];

  onLabelsChange(event: any) {

  onEnterKeyDown(event: any) { =' ', '-');

Best Regards,


bitjuice pro commented 3 years ago

Thanks very much Darmian: I used (keydown.enter) event

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • 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