3

我按照官方文档更新 Angular 应用程序,在更新所有内容后,当我运行时ng serve出现以下错误

ERROR in app/src/app/users/add/add.component.html:14:48 - error NG2345: Argument of type 'AbstractControl' is not assignable to parameter of type 'FormControl'.
  Type 'AbstractControl' is missing the following properties from type 'FormControl': registerOnChange, registerOnDisabledChange, _applyFormState

  <ng-container *ngFor="let error of errors(addNewUserForm.get('username'))">



   Error occurs in the template of component UserProfileComponent.
app/src/app/registration/dialog/dialog.component.html:1:1 - error NG8001: 'mat-horizontal-stepper' is not a known element:
1. If 'mat-horizontal-stepper' is an Angular component, then verify that it is part of this module.
2. If 'mat-horizontal-stepper' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

  <mat-horizontal-stepper linear #stepperRegistration>

mat-dialog-actions,mat-step等的mat-dialog-content相同错误

和...

Error occurs in the template of component DialogComponent.
app/src/app/registration/dialog/dialog.component.html:46:13 - error NG8002: Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'.

[errorStateMatcher]="matcher"

这是我的 package.json

"dependencies": {
    "@angular/animations": "^9.0.0-rc.10",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "^9.0.0-rc.10",
    "@angular/compiler": "^9.0.0-rc.10",
    "@angular/core": "^9.0.0-rc.10",
    "@angular/flex-layout": "^8.0.0-beta.27",
    "@angular/forms": "^9.0.0-rc.10",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "^9.0.0-rc.10",
    "@angular/platform-browser-dynamic": "^9.0.0-rc.10",
    "@angular/router": "^9.0.0-rc.10",
    "@angular/service-worker": "^9.0.0-rc.10",
    "@ngrx/effects": "^8.6.0",
    "@ngrx/schematics": "^8.6.0",
    "@ngrx/store": "^8.6.0",
    "@ngrx/store-devtools": "^8.6.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.4.1",
    "keycloak-angular": "^7.1.0",
    "keycloak-js": "^6.0.1",
    "popper.js": "^1.16.0",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.0-rc.10",
    "@angular-devkit/schematics": "^8.3.23",
    "@angular/cli": "^9.0.0-rc.10",
    "@angular/compiler-cli": "^9.0.0-rc.10",
    "@angular/language-service": "^9.0.0-rc.10",
    "@compodoc/compodoc": "^1.1.11",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "protractor": "~5.4.0",
    "rxjs-tslint-rules": "^4.28.0",
    "ts-node": "~7.0.0",
    "tslint": "^5.20.1",
    "tslint-angular": "^3.0.2",
    "tslint-sonarts": "^1.9.0",
    "typescript": "~3.7.5",
    "webpack-bundle-analyzer": "^3.6.0"
  }
4

2 回答 2

0

检查您的模块以获取组件对话框。您必须导入MatStepperModule. 同样更新您使用材料库中其他模块的模块,例如:

import {MatStepperModule} from '@angular/material/stepper';
import {MatDialogModule} from '@angular/material/dialog';

所以[errorStateMatcher]="matcher"上述解决方案中的错误应该修复它,因为它找不到组件组件并且它是@Input().

于 2020-01-27T06:27:32.063 回答
0

我可以通过更新延迟加载模块的路由来解决类似的错误

loadChildren: './some/route/some-route.module#SomeRouteModule',

loadChildren: () => import('./some/route.module').then(m => m.SomeRouteModule),
于 2020-05-11T11:36:32.143 回答