angular - 单击角度按钮时,步进器的 SelectedIndex 未更新
问题描述
当我单击指定的更新状态按钮时,步进器不会更新到提供的索引。
.html 文件:
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<h2>Connection Status</h2>
<button class="btn btn-primary waves-light" mdbWavesEffect (click)=openDialog()>Update Status</button>
<p>
<mat-horizontal-stepper linear #stepper>
<mat-step label="Connection Request Sent"></mat-step>
<mat-step label="Connection Response Received"></mat-step>
<mat-step label="Connection Established"></mat-step>
<mat-step label="Done"></mat-step>
</mat-horizontal-stepper>
</p>
ts文件:
import { Component, OnInit, ViewChild } from "@angular/core";
import { MatHorizontalStepper } from "@angular/material/stepper";
@Component({
selector: "app-stepper-test",
templateUrl: "./stepper-test.component.html",
styleUrls: ["./stepper-test.component.scss"]
})
export class StepperTestComponent implements OnInit {@
ViewChild(MatHorizontalStepper, {
static: false
})
stepper: MatHorizontalStepper;
constructor() {}
ngOnInit() {}
openDialog() {
this.stepper.selectedIndex = 2;
}
}
解决方案
推荐阅读
- c++ - 与显示警告的 string.size() 比较时 int 的签名
- android-youtube-api - 使用 YouTube Android Player API 时的数据隐私
- batch-file - 将特定文件类型移动到子文件夹中的批处理文件
- javascript - Javascript,更改对象值然后调用 Object.keys( ).forEach 中的函数
- asp.net - ASP.NET CORE MVC - 将相同的操作重定向到视图中的另一个控制器
- sql - 如何从 SQL 中的 2 个表中获取最小值和最大值
- xamarin.forms - Xamarin Forms Converter 在页面消失时被调用?
- awk - 使用 ksh(AIX) 时如何在 awk 中调用变量?
- r - 使用 ggplot2 的箱线图看起来很压缩
- r - write.csv() 从 Mac OS 写入的结果与从 Windows 10 写入的结果不同?