I work on angular 9 I face issue when add angular material auto complete text box
error NG8003: No directive found with exportAs 'matAutocomplete'.
I try to add lines below to app.module to solve issue but issue still exist
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatFormFieldModule } from '@angular/material/form-field';
imports: [
FormsModule,
MatFormFieldModule
auto complete component.html
{{exp.itemName}}
current Packages Exist on angular project is :
"@agm/core": "^1.1.0",
"@amcharts/amcharts4": "^4.9.26",
"@amcharts/amcharts4-geodata": "^4.1.15",
"@angular/animations": "^9.1.13",
"@angular/cdk": "^12.1.1",
"@angular/common": "~9.0.0",
"@angular/compiler": "~9.0.0",
"@angular/core": "~9.0.0",
"@angular/forms": "~9.0.0",
"@angular/localize": "^9.0.0",
"@angular/material": "^11.2.13"
so How to solve this issue please ?
ahmed elbarbaryPosted Aug 12, 2021, 11:52 AM
Jefferson S. MottaPosted Aug 12, 2021, 2:36 AM
Check: angular - There is no directive with exportAs set to matAutocomplete - Stack Overflow
but it's in beta @angular/cdk - npm (npmjs.com)
To use mat-form-field, you have to update your @angular/material and @angular/cdk versions to atleast 2.0.0-beta.12. Use the following commands to update:
npm install @angular/[email protected] npm install @angular/[email protected]
Then, you have import the following in your AppModule:
import { MatAutocompleteModule, MatFormFieldModule } from '@angular/material'; @NgModule({ imports: [ .... MatAutocompleteModule, MatFormFieldModule, .... ], .... }) export class AppModule { }
Here is a working StackBlitz demo using version 2.0.0-beta.12