0

角度では、個々のステップが別々のコンポーネントであるリニアステッパーを使用できますか?たとえば:リニアマット - 水平ステッパーで別々のコンポーネントを使用する

TypeError: Cannot read property 'invalid' of undefined:私はこれをしようとすると

<mat-horizontal-stepper [linear]="isLinear"> 
    <mat-step [stepControl]="firstFormGroup" label="Some Form"> 
     <first-component></first-component> 
    </mat-step> 
    <mat-step [stepControl]="secondFormGroup" label="Another Form"> 
     <second-component></second-component> 
    </mat-step> 
    <mat-step [stepControl]="thirdFormGroup" label="Review"> 
     <third-component></third-component> 
    </mat-step> 
</mat-horizontal-stepper> 

は、私がmatStepperNextボタンを押す時に、次のエラーメッセージが表示されます。

+0

component.tsコードを確認できますか?私の推測では、1つ以上のstepcontrol変数がコンポーネントで定義されていないということです。 –

+0

@BrianWright私はplnkrに最小限の例をまとめようとしましたが、コンポーネントの1つを見つけることができないと私に伝えているので、何かをねじにする必要があります... https://embed.plnkr.co/5Yx4RTIrIHklRtH5rJHO /(私が上で話している問題と全く違う)。 – Locke

+0

心配する必要はありません、下記の私の答えを参照してください。また、これをチェックしてください:https://stackblitz.com/ –

答えて

0

[OK]を、私はいくつかの問題を参照してくださいと思う:

<mat-horizontal-stepper [linear]="isLinear"> 
    <mat-step [stepControl]="foodFormGroup"> 
    <food-selection></food-selection> 
    </mat-step> 
    <mat-step [stepControl]="pieFormGroup"> 
    <pie-selection></pie-selection> 
    </mat-step> 
</mat-horizontal-stepper> 

foodFormGrouppieFormGroupはあなたの厳しい-choice.component.tsファイル(どの、ところでスペルミスさで定義する必要があります

:あなたの例のコード)に

はここで、これはどのように見えるかのドキュメントからの例()です

import {Component} from '@angular/core'; 
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; 

/** 
* @title Stepper overview 
*/ 
@Component({ 
    selector: 'stepper-overview-example', 
    templateUrl: 'stepper-overview-example.html', 
    styleUrls: ['stepper-overview-example.css'] 
}) 
export class StepperOverviewExample { 
    isLinear = false; 
    firstFormGroup: FormGroup; 
    secondFormGroup: FormGroup; 

    constructor(private _formBuilder: FormBuilder) { } 

    ngOnInit() { 
    this.firstFormGroup = this._formBuilder.group({ 
     firstCtrl: ['', Validators.required] 
    }); 
    this.secondFormGroup = this._formBuilder.group({ 
     secondCtrl: ['', Validators.required] 
    }); 
    } 
} 

また、あなたの例ではmodule.tsファイルは表示されません。これは、コンポーネントファイルではなく、@ angle/materialモジュールをインポートする場所です。

私は、角度材料マテリアルをもう一度与えることをお勧めします。 https://material.angular.io/components/stepper/overview

+0

ありがとうございます。私は打ち間違いでヘッドアップを感謝し、それは私を壁に追いやっていた。私はstackblitzデモでメインポストにあなたのコメントに応えました。 – Locke

関連する問題