0

次のような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>

シナリオでは、最初はすべてのチェックボックス (サービス テーブル内のサービスの数に応じて) がオフになっており、テキスト ボックスが無効になっています。ユーザーは目的のサービスにチェックを入れることができます。これにより、ユーザーが選択したサービスのリストとそのリストをレコードに保存すると、対応するテキスト ボックスが有効になります。価格は、ServiceID と Price の 2 つの属性を持つ ProductProfile.PriceList になります。

コントローラーで 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 に答える