mat-button-toggle' 不是已知元素:即使在将导入添加到 app.module.ts 之后
mat-button-toggle' is not a known element: Even after adding imports to app.module.ts
我已将 MatButtonToggleModule 添加到 app.module.ts。即使在那之后,也显示 mat-button-toggle 不是已知元素。我已经重新启动了我的代码编辑器,我 运行 npm install。即使在做了这些之后它仍然显示相同。我也检查了其他解决方案,但一切都说只从 angular material.
导入 MatButtonToggleModule
I have attatched the error image
App.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {FormsModule, ReactiveFormsModule} from '@angular/forms'
import { AppComponent } from './app.component';
import { IonicModule } from '@ionic/angular';
import { environment } from '../environments/environment';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { AppRoutingModule } from './app-routing.module';
import {MatTooltipModule} from '@angular/material/tooltip';
import { DashComponent } from './components/dash/dash.component';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatCardModule } from '@angular/material/card';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { LayoutModule } from '@angular/cdk/layout';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
import { MiniCardComponent } from './components/dash/mini-card/mini-card.component';
import { NavComponent } from './components/nav/nav.component';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatListModule } from '@angular/material/list';
import {MatSelectModule} from '@angular/material/select';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { ConfigurationComponent } from './components/configuration/configuration.component';
import {MatDividerModule} from '@angular/material/divider';
import {MatExpansionModule} from '@angular/material/expansion';
import { MatInputModule } from '@angular/material/input';
import {MatTreeModule} from '@angular/material/tree';
import { SidebarComponent } from './components/sidebar/sidebar.component';
import { FooterComponent } from './components/footer/footer.component';
import {MatDialogModule} from '@angular/material/dialog';
import { AccountComponent } from './components/account/account.component';
import { ConfirmPromptComponent } from './components/confirm-prompt/confirm-prompt.component';
import { CookieModule } from 'ngx-cookie';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { ServiceWorkerModule } from '@angular/service-worker';
import { UpdatePromptComponent } from './components/update-prompt/update-prompt.component';
import { NgChartsModule } from 'ng2-charts';
import { DatePipe } from '@angular/common'
import { JwtInterceptor } from './modules/authentication/helpers/jwt.interceptor';
import { ErrorInterceptor } from './modules/authentication/helpers/error.interceptor';
import { LoginComponent } from './modules/authentication/components/login/login.component';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatRadioModule} from '@angular/material/radio';
@NgModule({
declarations: [
AppComponent,
DashComponent,
MiniCardComponent,
NavComponent,
ConfigurationComponent,
LoginComponent,
SidebarComponent,
FooterComponent,
AccountComponent,
ConfirmPromptComponent,
UpdatePromptComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
NgbModule,
AppRoutingModule,
MatTooltipModule,
MatGridListModule,
MatCardModule,
MatMenuModule,
MatIconModule,
MatButtonModule,
LayoutModule,
BrowserAnimationsModule,
MatTableModule,
MatPaginatorModule,
MatSortModule,
MatToolbarModule,
MatSidenavModule,
MatListModule,
MatSelectModule,
HttpClientModule,
MatDividerModule,
MatExpansionModule,
MatInputModule,
MatTreeModule,
MatDialogModule,
MatButtonToggleModule,
MatRadioModule,
NgChartsModule,
CookieModule.forRoot(),
MatProgressSpinnerModule,
ServiceWorkerModule.register('./ngsw-worker.js', {
enabled: environment.production,
// Register the ServiceWorker as soon as the app is stable
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000'
})
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
DatePipe
],
bootstrap: [AppComponent]
})
export class AppModule { }
[enter image description here][1]
[1]: https://i.stack.imgur.com/GI7Qi.png
我检查了您的文件,发现您创建了一个名为 item-wise-report 的组件。这个组件没有自己的模块,是吗?它应该在“app.module.ts”中声明。
否则,item-wise-report将无法使用app.module.ts中导入的MatButtonToggleModule。
希望对你有帮助,问候
我已将 MatButtonToggleModule 添加到 app.module.ts。即使在那之后,也显示 mat-button-toggle 不是已知元素。我已经重新启动了我的代码编辑器,我 运行 npm install。即使在做了这些之后它仍然显示相同。我也检查了其他解决方案,但一切都说只从 angular material.
导入 MatButtonToggleModuleI have attatched the error image
App.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {FormsModule, ReactiveFormsModule} from '@angular/forms'
import { AppComponent } from './app.component';
import { IonicModule } from '@ionic/angular';
import { environment } from '../environments/environment';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { AppRoutingModule } from './app-routing.module';
import {MatTooltipModule} from '@angular/material/tooltip';
import { DashComponent } from './components/dash/dash.component';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatCardModule } from '@angular/material/card';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { LayoutModule } from '@angular/cdk/layout';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatSortModule } from '@angular/material/sort';
import { MiniCardComponent } from './components/dash/mini-card/mini-card.component';
import { NavComponent } from './components/nav/nav.component';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatListModule } from '@angular/material/list';
import {MatSelectModule} from '@angular/material/select';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { ConfigurationComponent } from './components/configuration/configuration.component';
import {MatDividerModule} from '@angular/material/divider';
import {MatExpansionModule} from '@angular/material/expansion';
import { MatInputModule } from '@angular/material/input';
import {MatTreeModule} from '@angular/material/tree';
import { SidebarComponent } from './components/sidebar/sidebar.component';
import { FooterComponent } from './components/footer/footer.component';
import {MatDialogModule} from '@angular/material/dialog';
import { AccountComponent } from './components/account/account.component';
import { ConfirmPromptComponent } from './components/confirm-prompt/confirm-prompt.component';
import { CookieModule } from 'ngx-cookie';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { ServiceWorkerModule } from '@angular/service-worker';
import { UpdatePromptComponent } from './components/update-prompt/update-prompt.component';
import { NgChartsModule } from 'ng2-charts';
import { DatePipe } from '@angular/common'
import { JwtInterceptor } from './modules/authentication/helpers/jwt.interceptor';
import { ErrorInterceptor } from './modules/authentication/helpers/error.interceptor';
import { LoginComponent } from './modules/authentication/components/login/login.component';
import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {MatRadioModule} from '@angular/material/radio';
@NgModule({
declarations: [
AppComponent,
DashComponent,
MiniCardComponent,
NavComponent,
ConfigurationComponent,
LoginComponent,
SidebarComponent,
FooterComponent,
AccountComponent,
ConfirmPromptComponent,
UpdatePromptComponent
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
NgbModule,
AppRoutingModule,
MatTooltipModule,
MatGridListModule,
MatCardModule,
MatMenuModule,
MatIconModule,
MatButtonModule,
LayoutModule,
BrowserAnimationsModule,
MatTableModule,
MatPaginatorModule,
MatSortModule,
MatToolbarModule,
MatSidenavModule,
MatListModule,
MatSelectModule,
HttpClientModule,
MatDividerModule,
MatExpansionModule,
MatInputModule,
MatTreeModule,
MatDialogModule,
MatButtonToggleModule,
MatRadioModule,
NgChartsModule,
CookieModule.forRoot(),
MatProgressSpinnerModule,
ServiceWorkerModule.register('./ngsw-worker.js', {
enabled: environment.production,
// Register the ServiceWorker as soon as the app is stable
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000'
})
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
DatePipe
],
bootstrap: [AppComponent]
})
export class AppModule { }
[enter image description here][1]
[1]: https://i.stack.imgur.com/GI7Qi.png
我检查了您的文件,发现您创建了一个名为 item-wise-report 的组件。这个组件没有自己的模块,是吗?它应该在“app.module.ts”中声明。 否则,item-wise-report将无法使用app.module.ts中导入的MatButtonToggleModule。
希望对你有帮助,问候