angular - 如何在不使用动态变量名称的 ngmodel 的情况下将 mat-slider 的值绑定到 angular 的 mat-input?
问题描述
我想将我的值绑定mat-slider
到mat-input
.
我不需要使用ngModel
双向绑定,因为我使用的是formcontrolname
.
我的表单控件名称由两部分组成。第一部分是固定的,另一部分是可变的。
这是我的html部分:
<mat-label>{{relSizFilteredTitle}}</mat-label>
<h3>Minimum value :</h3>
<mat-slider
invert="false"
max="80"
min="50"
step="1"
thumbLabel="true"
[(value)]="relSizFilteredTitle + '_min'"
tickInterval="true"
[formControlName]="relSizFilteredTitle + '_min'"
vertical="false">
</mat-slider>
<input matInput [formControlName]="relSizFilteredTitle + '_min'"
type="number"
autocomplete="false"
min="50"
max="80"
required
placeholder="">
如您所见,我打算使用两种方式绑定 value 属性。但 angular 不接受relSizFilteredTitle + '_min'
作为变量名。
您可能应该知道在 .ts 文件中我有这些:
goForward(stepper: MatStepper, operation?: string, element?: any) {
this.operation = operation;
stepper.next();
this.secondFormGroup.valueChanges.subscribe(data => this.onSecondFormGroupValueChange(data));
}
onSecondFormGroupValueChange(data) {
// ==> I want to do sth here.
console.log(data);
}
如何绑定 mat-slider 和 mat-input 的值,反之亦然?
解决方案
推荐阅读
- angular - Ionic 4 - 如何将组件动态添加到页面?
- networking - 无法查看从 terraform 资源创建的 EKS 集群
- r - 在另一个类的方法中使用一个类的方法
- python - 寻找系列中的最低值
- asp.net-core - 弹性搜索 Nest Client 很慢
- react-native - 将自定义列表传递给 React 本机导航 5.5 DrawerItemList
- python - 如何使用用户名作为 slug 参数 django rest 框架获取 url
- arrays - perl 中是否有一个函数来检查 2 个数组是否包含相同的内容(尽管不一定是相同的顺序)?
- c - 从 C 中的 GtkMenuItem 捕获关键事件
- c# - 我将如何编写正则表达式来匹配数字或字母数字单词,而不是没有数字的单词?