Ngx-bootstrap: Typeahead doesn't work (isn't a known property of 'input')

Created on 18 Aug 2017  路  6Comments  路  Source: valor-software/ngx-bootstrap

angular v4.0.0
ngx-bootstrap v1.8.1

Imported module

import { TypeaheadModule } from 'ngx-bootstrap/typeahead';  

@NgModule({
..
imports: [
 TypeaheadModule.forRoot(),
..
])

When using

<input
            [(ngModel)]="selected"
            [typehead]="products"
            typeaheadOptionField="name"
            class="form-control"/>

having issue

Can't bind to 'typehead' since it isn't a known property of 'input'. ("                
                <input
                           [(ngModel)]="selected"
                           [ERROR ->][typehead]="products"
                           typeaheadOptionField="name"

and warning before the issue

Template parse warnings:
The <template> element is deprecated. Use <ng-template> instead ("
<!-- inject options list template -->
[WARNING ->]<template [ngTemplateOutlet]="optionsListTemplate || (isBs4 ? bs4Template : bs3Template)"
  [ngOutlet"): ng:///TypeaheadModule/TypeaheadContainerComponent.html@2:0

Most helpful comment

@debslab hey, in 90% of cases you forgot to add import of Typeahead module to module where your component is declared

All 6 comments

  1. seems you need ngx-bootstrap@next version
  2. angular DI is designed in a way, that you need to import components module in any child\lazy loaded modules
    but call forRoot only in root module, to provide required services

I am using ngx-bootstrap 1.9.3. I am getting same error. I have added the required module in root module as well as in lazily loaded module (not using forroot in latter).
Following is error:
ERROR Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'typeahead' since it isn't a known property of 'input'. ("<div class="modal-body"> <div class="card-block"> <input [(ngModel)]="selected" [ERROR ->][typeahead]="states" class="form-control">

Please let me know how to resolve

@debslab hey, in 90% of cases you forgot to add import of Typeahead module to module where your component is declared

thanks, I have added to root level module, but I missed it to add at immediate level module.

@debslab hey, in 90% of cases you forgot to add import of Typeahead module to module where your component is declared

but in my case, all injection and declaration are done then also it is showing error

After adding in intermediate module, I m getting this error
i m using "ngx-bootstrap": "^6.2.0",


ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(SalesActivitiesModule)[ComponentLoaderFactory -> ComponentLoaderFactory -> ComponentLoaderFactory -> ComponentLoaderFactory]:
NullInjectorError: No provider for ComponentLoaderFactory!
NullInjectorError: R3InjectorError(SalesActivitiesModule)[ComponentLoaderFactory -> ComponentLoaderFactory -> ComponentLoaderFactory -> ComponentLoaderFactory]:
NullInjectorError: No provider for ComponentLoaderFactory!
at NullInjector.get (core.js:1013)
at R3Injector.get (core.js:11122)
at R3Injector.get (core.js:11122)
at R3Injector.get (core.js:11122)
at NgModuleRef$1.get (core.js:24243)
at R3Injector.get (core.js:11122)
at NgModuleRef$1.get (core.js:24243)
at Object.get (core.js:22142)
at getOrCreateInjectable (core.js:4079)
at Module.傻傻directiveInject (core.js:14651)
at resolvePromise (zone.js:1215)
at resolvePromise (zone.js:1165)
at zone.js:1277
at ZoneDelegate.invokeTask (zone.js:407)
at Object.onInvokeTask (core.js:27474)
at ZoneDelegate.invokeTask (zone.js:406)
at Zone.runTask (zone.js:179)
at drainMicroTaskQueue (zone.js:583)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghiscoding picture ghiscoding  路  3Comments

ctrl-brk picture ctrl-brk  路  3Comments

webdev48 picture webdev48  路  3Comments

juanitavollmering picture juanitavollmering  路  3Comments

KimBum picture KimBum  路  3Comments