Yuvals
Yuvals

Reputation: 3266

ng2-tag-input separatorKeys not working

I am trying to use ng2-tag-input module , with a very basic configuration:

import { Component } from '@angular/core';

@Component({
  moduleId: module.id,
  selector: 'search-form',
  template: `<tag-input [(ngModel)]='items'></tag-input>`
})

export class SearchFormComponent {



    items = ['Pizza', 'Pasta', 'Parmesan'];
    options = {
        placeholder: "+ term",
        secondaryPlaceholder: "Enter a new term",
        separatorKeys: [32,13]
    }
    onItemAdded(item) {

    }
    onItemRemoved(item) {

    }


}

Everything works, except separatorKeys - it has no effect, when I type space key (keyCode=32), it behaves as a normal space instead of a separator.

On the demo page their example works fine, is this something that can be related to NG2 version?

https://github.com/Gbuomprisco/ng2-tag-input

Upvotes: 1

Views: 955

Answers (2)

David Sajdl
David Sajdl

Reputation: 174

add separatorKeys into html template

@Component({
  moduleId: module.id,
  selector: 'search-form',
    template: `<tag-input [(ngModel)]='items'
                          [separatorKeyCodes]="[32,13]"></tag-input>`
})

Upvotes: 0

Giancarlo PSK
Giancarlo PSK

Reputation: 231

I am the author of the module.

It does not seem you are setting the separatorKeys attribute in your template. Have a look at http://www.webpackbin.com/NJy38G8kM for the source code.

Upvotes: 1

Related Questions