【发布时间】:2019-04-28 18:46:03
【问题描述】:
我正在尝试将 mat-horizontal-stepper 中每个步骤的组件分开,如下面的 html 页面所示。
<mat-horizontal-stepper [linear]="true" #stepper>
<mat-step [stepControl]="selectAdvType">
<ng-template matStepLabel>
<div class="text-center">
<mat-icon>queue_play_next</mat-icon><br /><span>Select Adv Type</span>
</div>
</ng-template>
<app-advertisement-type></app-advertisement-type>
</mat-step>
<mat-step [stepControl]="selectCarAdvType">
<ng-template matStepLabel>
<div class="text-center">
<mat-icon>directions_car</mat-icon><br /><span>Select Car</span>
</div>
</ng-template>
<app-select-car-adv></app-select-car-adv>
</mat-step>
<mat-step>
<ng-template matStepLabel>
<div class="text-center">
<mat-icon>description</mat-icon><br /><span>Select Features</span>
</div>
</ng-template>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button (click)="stepper.reset()">Reset</button>
</div>
</mat-step>
</mat-horizontal-stepper>
应用广告类型组件
<form [formGroup]="selectAdvType">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
app-select-car-adv 组件
<form [formGroup]="selectCarAdvType">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
组件类的验证
export class AdvertisementTypeComponent implements OnInit {
selectAdvType: FormGroup;
constructor(private _formBuilder: FormBuilder) { }
ngOnInit() {
this.selectAdvType = this._formBuilder.group({
firstCtrl: ['', Validators.required]
});
}
}
由于线性功能不起作用。我,能够导航到另一个组件。我该如何解决这个问题。
【问题讨论】:
-
这方面有什么更新吗?
-
谁能给出我们如何实现上述目标的答案
-
你找到解决办法了吗?
标签: javascript angular typescript angular-material angular5