0

我有 Id like 的服务表

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 循环来做到这一点,但失败了

4

1 回答 1

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>
于 2016-07-14T06:10:42.493 回答