oferh / ng2-completer

Angular 2 autocomplete component
http://oferh.github.io/ng2-completer/
MIT License
347 stars 172 forks source link

Can't bind to [Attribute] since it isn't a known property of 'ng2-completer'. #237

Closed marciomsm closed 7 years ago

marciomsm commented 7 years ago

I am getting these erros bellow. Does anyone know what I need to do to fix it?

Can't bind to 'inputName' since it isn't a known property of 'ng2-completer'.

Can't bind to 'disableInput' since it isn't a known property of 'ng2-completer'.

Can't bind to 'datasource' since it isn't a known property of 'ng2-completer'.

Here is my code:

<ng2-completer name="markets"
             [(ngModel)]="dataStr"
             [inputName]="'fieldName'"
             [disableInput]="!isLoaded"
             [datasource]="dataList"
             [openOnFocus]="true"
             [minSearchLength]="0"
             [placeholder]="'Choose a item'"
             (selected)="getSelected($event)">
</ng2-completer>

Thanks.

oferh commented 7 years ago

have you imported Ng2CompleterModule in your AppModule?

marciomsm commented 7 years ago

@oferh yes, I imported.

import { Ng2CompleterModule } from 'ng2-completer';

Just a thing that I forgot to say, I am getting these erros in my unit test.

Thank you very much for your quick answer. I really appreciate it.

marciomsm commented 7 years ago

@oferh I discovered how to fix this problem.

On app.component.spec.ts we need to add CUSTOM_ELEMENTS_SCHEMA.

import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './../app.component';
import { RouterTestingModule } from '@angular/router/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

describe('AppComponent', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      schemas: [ CUSTOM_ELEMENTS_SCHEMA ],
      declarations: [AppComponent],
      imports: [RouterTestingModule]
    });
    TestBed.compileComponents();
  });