仅使用一个按钮获取倍数的值
我正在尝试同时获得倍数的结果... 目前,我有一个结构可以一个接一个地获得结果,但是我需要发送所有结果...
我的HTML代码:
<form (ngSubmit)="onSubmit(f)" #f="ngForm" *ngFor="let x of selectedValue; index as i">
<mat-card >
<mat-card-title class="title-card">
<span>{{x.name}}</span>
</mat-card-title>
<mat-card-content *ngFor="let param of x.modelParameter; index as i">
<div class="param-title">
<span><b>{{param.name}}</b></span>
</div>
<div class="set-slider" *ngIf="param.type === 'continuous'">
<label class="gridSizeValue"><b>{{param.values_arr[0]}}</b></label>
<mat-slider #gridsize (change)="updateSetting($event)" class="slider" thumbLabel
tickInterval="1" [displayWith]="formatLabel" min="{{param.values_arr[0]}}"
max="{{param.values_arr[1]}}" aria-label="units" class="form-control" ngModel name="{{param.name}}">
</mat-slider>
<label class="gridSizeValue"><b>{{param.values_arr[1]}}</b></label>
</div>
<div class="set-categorical" *ngIf="param.type === 'categorical'">
<mat-form-field appearance="outline">
<mat-select
class="form-control"
ngModel name="option">
<mat-option *ngFor="let op of param.values_arr" [value]="op">
{{op}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</mat-card-content>
</mat-card>
<button mat-raised-button type="submit" class="save-button">Send Models</button>
</form>
我试图将按钮放在外部方法中,但它不起作用,而且我也很试图通过ngmodel获得值,但它也不起作用。
你有建议吗?
I'm trying to get the result for multiples forms at same time...
Currently, I have a structure to get the result one by one but I need to send the result of all of them...
My html code:
<form (ngSubmit)="onSubmit(f)" #f="ngForm" *ngFor="let x of selectedValue; index as i">
<mat-card >
<mat-card-title class="title-card">
<span>{{x.name}}</span>
</mat-card-title>
<mat-card-content *ngFor="let param of x.modelParameter; index as i">
<div class="param-title">
<span><b>{{param.name}}</b></span>
</div>
<div class="set-slider" *ngIf="param.type === 'continuous'">
<label class="gridSizeValue"><b>{{param.values_arr[0]}}</b></label>
<mat-slider #gridsize (change)="updateSetting($event)" class="slider" thumbLabel
tickInterval="1" [displayWith]="formatLabel" min="{{param.values_arr[0]}}"
max="{{param.values_arr[1]}}" aria-label="units" class="form-control" ngModel name="{{param.name}}">
</mat-slider>
<label class="gridSizeValue"><b>{{param.values_arr[1]}}</b></label>
</div>
<div class="set-categorical" *ngIf="param.type === 'categorical'">
<mat-form-field appearance="outline">
<mat-select
class="form-control"
ngModel name="option">
<mat-option *ngFor="let op of param.values_arr" [value]="op">
{{op}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</mat-card-content>
</mat-card>
<button mat-raised-button type="submit" class="save-button">Send Models</button>
</form>
I was trying to put the button outside method but it does not work, and also I was trying to get the value by ngModel but it does not works neither.
Do you have any suggest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在循环中具有模板参考变量时,当您使用此变量时,将“范围”对每个迭代进行“范围”。
您可以使用ViewChildren来获取所有元素具有相同的“模板参考变量”
一个按钮类型在循环外提交可以调用函数的元素(您可以拨打提交或以其他方式调用)
您的功能提交,
现在我们得到表单。您如何创建数据?
顺便说一句,您想看一下使用 [(ngmodel)] 使用数组或< a href =“ https://angular.io/guide/reeactive-forms” rel =“ nofollow noreferrer”> reactiveforms
When you has a template reference variable in a loop, when you use this variable is "scoped" to each iteration.
You can use ViewChildren to get all elements with the same "template reference Variable"
A button type submit outside the loop can call to a function (you can call submit or in another way)
You function submit
Now we get the forms the question is: how you can create your data?
BTW perhafs you want to take a look to use [(ngModel)] using an array or ReactiveForms