小编use*_*109的帖子

如何在 Angular 5 中使用材料步进器

我目前对 Angular 有点陌生,我正试图弄清楚如何制作一个简单的步进器,它可以 (1) -- (2) -- (3)。

我有 html 作为 app.component.html

<mat-horizontal-stepper [linear]="true" #stepper>
    <mat-step label="Step 1">
        step 1
    </mat-step>
    <mat-step label="Step 2">
        step 2
    </mat-step>
</mat-horizontal-stepper>
Run Code Online (Sandbox Code Playgroud)

但是,我需要在打字稿中导入和执行哪些操作才能使其工作?我有 app.component.ts 作为

import { Component, ViewChild } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule } from '@angular/material';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent {
  @ViewChild('stepper') stepper;
  changeStep(index: number) {
    this.stepper.selectedIndex = index;
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript frontend material-design angular-material2 angular

1
推荐指数
1
解决办法
2万
查看次数