Unexpected "MatSpinner" directive imported by the "AppModule" module. Add Note @NgModule

Angular 5 -

here are the npm modules (package.json) -

   "@angular/animations": "^5.0.0",
    "@angular/cdk": "^5.0.0-rc.2",
    "@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-rc.2",
    "@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"

I use Angular Spinner material as the MatSpinner directive from the material module

import { MatSpinner } from "@angular/material";
@NgModule({
imports: [

MatSpinner
],
declarations: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

Here is the HTML:

<mat-spinner></mat-spinner>

I get ERROR -

Unexpected "MatSpinner" directive imported by the "AppModule" module. Add the @NgModule annotation.

+24
source share
3 answers

In your module application, you usually import the MatProgressSpinnerModule, not the MatSpinner. MatSpinner will be imported into your component.

+38
source

MatSpinner & MatProgressSpinner MatProgressSpinnerModule.

,

  • @NgModule
  • . @NgModule

MatProgressSpinnerModule, MatProgressSpinnerModule @NgModule.

import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';

@NgModule({
  imports: [
    MatProgressSpinnerModule
  ],
  declarations: [],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
+9

, , . ,

, . , , , , , . MatProgressSpinnerModule

0

Source: https://habr.com/ru/post/1690280/


All Articles