[英]Unexpected directive 'MatSpinner' imported by the module 'AppModule'. Please add a @NgModule annotation
Angular 5 - 角5 -
here are the npm modules (package.json)- 这是npm模块(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 am using Angular material Spinner as MatSpinner Directive from Material module 我使用Angular材质Spinner作为Material模块的MatSpinner指令
import { MatSpinner } from "@angular/material";
@NgModule({
imports: [
MatSpinner
],
declarations: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Here is the HTML: 这是HTML:
<mat-spinner></mat-spinner>
I am Getting an ERROR- 我得到一个错误 -
Unexpected directive 'MatSpinner' imported by the module 'AppModule'. 由模块'AppModule'导入的意外指令'MatSpinner'。 Please add a @NgModule annotation.
请添加@NgModule注释。
In your app-module, you would generally import MatProgressSpinnerModule, not MatSpinner. 在你的app-module中,你通常会导入MatProgressSpinnerModule,而不是MatSpinner。 MatSpinner would be imported in your component.
MatSpinner将导入您的组件中。
MatSpinner & MatProgressSpinner are component and already part of MatProgressSpinnerModule . MatSpinner和MatProgressSpinner是组件,已经是MatProgressSpinnerModule的一部分。
In Angular, 在Angular,
As both the components are available in MatProgressSpinnerModule , you should add MatProgressSpinnerModule in imports of your @NgModule .
由于这两个组件都在MatProgressSpinnerModule中可用, 因此您应该在@NgModule的导入中添加MatProgressSpinnerModule 。
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
@NgModule({
imports: [
MatProgressSpinnerModule
],
declarations: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.