Search code examples
angularngx-chips

add tags dynamically on Tab and Spacebar event in ngx-chips


Please Anyone tell me how add tags dynamically on Tab and Spacebar event in ngx-chips.

ngx-chips


Solution

  • Use separatorKeyCodes (number[]) or separatorKeys (string[])

     <div class="force-to-the-bottom">
      <tag-input [ngModel]="['hardocoded-item']" [separatorKeyCodes]="[32,9]">
      <tag-input-dropdown
        [autocompleteItems]="items"
        [showDropdownIfEmpty]="true"
        [dynamicUpdate]="false">
     </tag-input-dropdown>
    

    https://stackblitz.com/edit/ngx-chips-example-miqu3i?file=app%2Fshared%2Ftag-input%2Ftag-input.component.html