从Angular 8升级到Angular 9-错误

时间:2020-01-27 06:19:46

标签: angular angular9

我会遵循官方文档来更新角度应用程序,并且在更新所有内容之后, 当我运行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-actionsmat-stepmat-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"
  }

2 个答案:

答案 0 :(得分:0)

检查模块的组件对话框。您必须导入MatStepperModule。类似地,更新您在物料库中使用其他模块的模块,例如:

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

因此上述解决方案[errorStateMatcher]="matcher"中的错误应将其修复,因为它找不到组件组件,而它是@Input()

答案 1 :(得分:0)

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

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

loadChildren: () => import('./some/route.module').then(m => m.SomeRouteModule),