简体   繁体   English

Angular:从 Angular 9/10 更新到 13 时,Mat-Progress-Spinner 无法识别不确定模式

[英]Angular: Mat-Progress-Spinner does not recognize indeterminate mode when updating from Angular 9/10 to 13

I am updating my Angular app from 9/10 to 13 and I've been following the official documentation here .我正在将我的 Angular 应用程序从 9/10 更新到 13,并且我一直在关注官方文档 I rewrote my old code accordingly to fit the new convention:我相应地重写了旧代码以适应新约定:

<mat-progress-spinner
    [color]="primary"
    [mode]="indeterminate">
  </mat-progress-spinner>

But apparently this does not compile... The error I get is:但显然这不能编译......我得到的错误是:

error TS2339: Property 'indeterminate' does not exist on type 'ComponentNameHere'.

Yes, I've imported the Mat-Progress-Spinner already in module.ts是的,我已经在 module.ts 中导入了 Mat-Progress-Spinner

UPDATE更新

If I remove the brackets from color and mode I get the following error:如果我从颜色和模式中删除括号,我会收到以下错误:

error NG8001: 'mat-progress-spinner' is not a known element:
1. If 'mat-progress-spinner' is an Angular component, then verify that it is part of this module.
2. If 'mat-progress-spinner' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

UPDATE 2更新 2

My module.ts looks like the following:我的 module.ts 如下所示:

import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
...
 imports: [
        BrowserModule,
        AppRoutingModule,
        ReactiveFormsModule,
        FormsModule,
        MDBBootstrapModule.forRoot(),
        Ng2SearchPipeModule,
        NgMatSearchBarModule,
        BrowserAnimationsModule,
        MatInputModule,
        WavesModule,
        InputsModule,
        ButtonsModule,
        HttpClientModule,
        MatIconModule,
        MatTableModule,
        MatCheckboxModule,
        MatSortModule,
        MatTabsModule,
        MatSelectModule,
        MatCheckboxModule,
        MatInputModule,
        MatTreeModule,
        MatButtonModule,
        MatDialogModule,
        MatProgressBarModule,
        MatDatepickerModule,
        MatNativeDateModule,
        MatTooltipModule,
        MatRadioModule,
        MatDividerModule,
        ModalModule,
        MatPaginatorModule,
        // Mat-Slide-Toggle
        MatProgressSpinnerModule,
        ...

Figured it out, I needed to remove the [] brackets from the bindings and it seems that some removed packages (due to no longer being maintained for newer versions of Angular) caused the issue.想通了,我需要从绑定中删除[]括号,似乎一些已删除的包(由于不再为较新版本的 Angular 维护)导致了这个问题。 Commented out their imports and the app seems to magically work.注释掉他们的导入,该应用程序似乎神奇地工作。

I removed (by commenting out) the ng-docx , angular-bootstrap-md and ng-mat-search-bar packages.我删除(通过注释掉) ng-docxangular-bootstrap-mdng-mat-search-bar包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM