Angular Material Stepper和Stackblitz示例的问题

时间:2019-01-31 15:53:23

标签: angular angular-material

我正在尝试使用Angular Material步进器版本。尝试了7.3.0。但是StackBlitz中的示例没有显示。浏览器视图为空白。我尝试过Chrome和Firefox

https://stackblitz.com/angular/enxykjbpeao?file=app%2Fstepper-overview-example.ts

在本地尝试时,我会击中

compiler.js:2426 Uncaught Error: Template parse errors:
Can't bind to 'formGroup' since it isn't a known property of 'form'. ("izontal-stepper [linear]="isLinear" #stepper>
  <mat-step [stepControl]="firstFormGroup">
    <form [ERROR ->][formGroup]="firstFormGroup">
      <ng-template matStepLabel>Fill out your name</ng-template>
      "): ng:///AppModule/StepperComponent.html@5:10
Can't bind to 'formGroup' since it isn't a known property of 'form'. ("
  </mat-step>
  <mat-step [stepControl]="secondFormGroup">
    <form [ERROR ->][formGroup]="secondFormGroup">
      <ng-template matStepLabel>Fill out your address</ng-template>
  "): ng:///AppModule/StepperComponent.html@16:10
    at syntaxError (compiler.js:2426)
    at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:20600)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:26146)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:26133)
    at compiler.js:26076

1 个答案:

答案 0 :(得分:0)

为时已晚,但我面临着同样的问题。我必须将ReactiveFormsModule添加到app.module.ts文件中。我在下面的行中添加了它:

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

imports: [
  FormsModule,
  ReactiveFormsModule
],