Ngx-chips: Tag input does not work without using ngModel

Created on 11 Aug 2017  路  9Comments  路  Source: Gbuomprisco/ngx-chips

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] support request/question

Notice: feature requests will be ignored, submit a PR if you'd like

Current behavior
When shooting ngModel does not work, it issues the following error on the console.

captura de tela de 2017-08-11 16-04-59

This is the html code in question
captura de tela de 2017-08-11 16-11-24

This way it is sending the error, and it does not work.

Expected behavior
I need the tag-input to work without ngModel only with formControlsName.

Minimal reproduction of the problem with instructions (if applicable)
I can not reproduce the error.

What do you use to build your app?. Please specify the version
Angular CLI

Angular version:

node: 6.11.1 os: linux x64 @angular/common: 4.3.0 @angular/compiler: 4.3.0 @angular/core: 4.3.0 @angular/forms: 4.3.0 @angular/http: 4.3.0 @angular/platform-browser: 4.3.0 @angular/platform-browser-dynamic: 4.3.0 @angular/router: 4.3.0 @angular/upgrade: 4.3.0 @angular/cli: 1.2.0 @angular/compiler-cli: 4.2.5

ngx-chips version:
v1.5.0

Browser:
Chrome

Most helpful comment

Just replace the object to an array

schedules: [[], Validators.required],

All 9 comments

It looks like you are using an object instead of an array

Yes, it is an array of objects. However I need to use without ngModel because this field is added dynamically. If I leave ngModel, it is repeating, everything I type in one field is transcribed to another

From the error message it seems it's an object of objects.. Can you double check that? Can you write here the structure of the model too?

This is the total part that competes with the example

tripA: this.formBuilder.group({
            origin: ['', Validators.required],
            destiny: ['', Validators.required],
            schedules: [{}, Validators.required],
            routes: this.formBuilder.array([
              this.initRouteItem()
            ])

There is and the dynamic part I'm adding to each click of the button

    return this.formBuilder.group({
      name: [''],
      schedules: [{}]
    });

My add button performs this function

  private addRoute(): void {
    const control = <FormArray>this.formLine.get('daysOperations').get('week').get('tripA').get('routes');
    control.push(this.initRouteItem());
  }

basically: what is schedules, what is its full structure?

Schedules is an array of string:
{"22:56", "21:24", "25:66"}

but I see an object

schedules: [{}, Validators.required],

Maybe that's the error, how can I improve this, what I need is a string array. But how?

Just replace the object to an array

schedules: [[], Validators.required],

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HDaghash picture HDaghash  路  4Comments

matthewerwin picture matthewerwin  路  5Comments

EnochGao picture EnochGao  路  4Comments

anikets43 picture anikets43  路  4Comments

Gbuomprisco picture Gbuomprisco  路  4Comments