Unexpected directive 'MatTab' imported by the module 'AppModule'. Please add a @NgModule annotation
See original GitHub issueBug, feature request, or proposal:
Bug.
What is the expected behavior?
Material components should be recognized.
What is the current behavior?
Throws error: “Unexpected directive MatXYZ…”.
What are the steps to reproduce?
Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.
Plunker starter (using on @master
): https://goo.gl/uDmqyY
StackBlitz starter (using latest npm
release): https://goo.gl/wwnhMV
(1) Create a new app using angular CLI.
(2) Add Angular Material dependencies following the Getting Started doc: https://material.angular.io/guide/getting-started
(3) Try “ng serve” and view the page error.
What is the use-case or motivation for changing an existing behavior?
N/A.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
tsc --version
Version 2.6.1
ng --version
Angular CLI: 1.5.0
Node: 6.11.5
OS: linux x64
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/cdk": "^5.0.0-rc0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.0-rc0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
Is there anything else we should know?
None of the material components works, MatList, MatTab, MatCheckbox, …
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Uncaught Error: Unexpected directive 'MatFormField' imported ...
Uncaught Error: Unexpected directive 'MatFormField' imported by the module 'AppModule'. Please add a @NgModule annotation. app.component.html < ...
Read more >Unexpected directive imported by the module please add a ...
A class that's already declared in another module, whether an app module, @NgModule, or third-party module. An array of directives imported from another...
Read more >Unexpected directive 'Slides' imported by the module ...
Hi! I'm trying to build a very simple app: taking pictures, saving them in an array and then displaying with a slide component....
Read more >unexpected directive imported by the module please add a ...
Coding example for the question unexpected directive imported by the module please add a @ngmodule annotation-angular.js.
Read more >Please add a @Pipe/@Directive/@Component annotation.
Unexpected value 'BrowserAnimationsModule' declared by the module. ... import { SharedModule } from '. ... module 't'. Please add a @NgModule annotation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to import
MatTabModule
, notMatTab
.wow - what an issue!! - was an import case issue (file on disk was blockPage.ts (and should have been blockpage.ts (import { BlockPage } from ‘./blockpage’; where not flagged as errors).