Staticinjectorerror when using Typeahead(ngx-bootstrap)

Asked

Viewed 39 times

0

I need to use typeahead in a Component, let’s call it component1. Typeahead is also being imported into another Component(let’s call component2) which is used within this same component1 as a modal, but are of different modules. When I import the typeahead module into component1 and keep in component2 it gives me that error

Component1.module:

@NgModule({
    imports: [
        CommonModule,
        FullCalendarModule,
        EventoModule,
        BloquearAgendaModalModule,
        ListaBloqueiosModalModule,
        RouterModule.forChild(agendaState),
        TypeaheadModule.forRoot()
    ],
    declarations: [AgendaComponent],
    schemas: [CUSTOM_ELEMENTS_SCHEMA]
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>

Component2.module:

@NgModule({
    imports: [CommonModule, FormsModule, ReactiveFormsModule, EnderecoModule, TypeaheadModule.forRoot()],
    declarations: [EventoComponent],
    exports: [EventoComponent],
    schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class EventoModule {}

ERROR Error: Uncaught (in Promise): Error: Staticinjectorerror(Coraprevineappmodule)[Typeaheaddirective -> Ngcontrol]: Staticinjectorerror(Platform: core)[Typeaheaddirective -> Ngcontrol]: Nullinjectorerror: No Provider for Ngcontrol! Error: Staticinjectorerror(Coraprevineappmodule)[Typeaheaddirective -> Ngcontrol]: Staticinjectorerror(Platform: core)[Typeaheaddirective -> Ngcontrol]: Nullinjectorerror: No Provider for Ngcontrol! At Nullinjector.get (core.js?09c9:8894) resolveat Token (core.js?09c9:9139) at tryResolveToken (core.js?09c9:9083) At Staticinjector.get (core.js?09c9:8980) resolveat Token (core.js?09c9:9139) at tryResolveToken (core.js?09c9:9083) At Staticinjector.get (core.js?09c9:8980) resolveat NgModuleDep (core.js?09c9:21119) at NgModuleRef_.get (core.js?09c9:21808) resolveat NgModuleDep (core.js?09c9:21119) resolveat Promise (zone.js?d135:831) resolveat Promise (zone.js?d135:788) at Eval (zone.js?d135:892) At Zonedelegate.invokeTask (zone.js?d135:423) At object.onInvokeTask (core.js?09c9:17279) At Zonedelegate.invokeTask (zone.js?d135:422) At Zone.runTask (zone.js?d135:195) drainat MicroTaskQueue (zone.js? d135:601)

1 answer

0

I was investigating, investigating and saw that what caused the problem was the lack of Formsmodule import that is necessary pro typeahead to have bind working.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.