我有服务表,ID为
ID Text
1 Cleaning
2 Washing
3 Folding
4 Drying
我使用api调用检索它们并获得了Json。我有另一张桌子,其中我有这些服务的价格以及产品ID,因此在添加产品时我想添加服务及其价格。为此,我使用api调用检索派生和id并在表中迭代它们,并使用相同的迭代生成文本框以输入特定服务的价格。这是我长时间挠头后制作的桌子。
<table id="dataTable" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>
Service
<i class="fa sort"></i>
</th>
<th>
Price
<i class="fa sort"></i>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="Record in ServiceList">
<td>
<span>
<input id={{Record.ID}} ng-model="Services[Record.ID]" ng-checked="Record.ID==ProductProfile.PriceList.ServiceID" type="checkbox">
<label for={{Record.ID}}>
{{Record.Text}}
</label>
</span>
</td>
<td><span> <input id={{Record.ID}} ng-model="PriceList[Record.Price]" ng-disabled="!Services[Record.ID]" class="col-lg-12" type="number"></span></td>
</tr>
</tbody>
该场景最初取消选中所有复选框(取决于服务表中的服务数量)并禁用文本框,用户可以勾选所需的服务,一旦用户将记录保存到所选列表中,这将启用相应的文本框服务及其价格将在ProductProfile.PriceList中,它有两个属性ServiceID和Price
我试图通过在我的控制器中使用for循环但是失败
来做到这一点答案 0 :(得分:0)
我是通过
完成的 <div class="col-lg-8">
<table id="dataTable" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>
Service
<i class="fa sort"></i>
</th>
<th>
Price
<i class="fa sort"></i>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="Record in ServiceList">
<td>
<span>
<input id={{Record.ServiceID}} ng-model="Record.IsExist" type="checkbox">
<label for={{Record.ServiceID}}>
{{Record.Text}}
</label>
</span>
</td>
<td><span> <input ng-model="Record.Price" ng-disabled="!Record.IsExist" class="col-lg-12" step="any" min="0" max="1000" type="number"></span></td>
</tr>
</tbody>
</table>
</div>