使用Ember hbs文件中的另一个td值加载td值

问题描述 投票:0回答:1

我有一个ember hbs组件,在其中有一个表,其中td的值应根据前一个td的值确定,这是我的hbs代码,有什么帮助吗?

                            <div class="row">
                            <div class="col-md-12">
                                {{#if model.novs}}
                                    <table class="table table-striped">
                                        <thead>
                                            <tr>
                                                <th>Notice#</th>
                                                <th>Type</th>
                                                <th>Violation</th>
                                                <th>Inspection Item</th>
                                                <th>
                                                    Action
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>                                               
                                            {{#each  model.novs as |nov index|}}
                                            <tr>
                                                <td>{{nov.NOVNumber}}</td>
                                                <td>{{nov.NOVNoticeTypeName}} {{nov.ViolationTypeName}}</td>
                                                <td>
                                                    {{#each  nov.Violations as |novv index|}}
                                                    {{novv.ViolationNumber}}
                                                    {{novv.Year}}
                                                    {{novv.Make}}
                                                    {{novv.Model}}
                                                    {{#if novv.Vin}}(VIN#:
                                                    {{novv.Vin}})
                                                    {{/if}}
                                                    <br />
                                                    {{/each}}
                                                </td>
                                                <td>
                                                    {{#each  model.result.items as |novi index|}}
                                                    {{novi.itemNum}}
                                                    <br />
                                                    {{/each}}
                                                </td>
                                                <td>
                                                    {{#if isResCompletedStatus}}
                                                    <div class="btn btn-xs btn-default" onclick={{action "editNov" nov.NOVId}}>
                                                        <i class="fa fa-eye"></i>
                                                        View Notice
                                                    </div>
                                                    <div class="btn btn-xs btn-default" onclick={{action "generatePreCase" nov.NOVId }}>
                                                        <i class="fa fa-file"></i>
                                                        Generate Investigation
                                                    </div>
                                                    {{else}}
                                                    <div class="btn btn-xs btn-default" onclick={{action "editNov" nov.NOVId}}>
                                                        <i class="fa fa-edit"></i>
                                                        Edit Notice
                                                    </div>
                                                    {{/if}}
                                                </td>
                                            </tr>
                                            {{/each}}
                                        </tbody>
                                    </table>
                                {{else}}
                                    {{#unless isResCompletedStatus}}
                                        {{#link-to 'result.details.nov.details' 0 disabled=isResFormDisabledBoolean}}
                                            <div class="well text-center no-margin">
                                                Click here to add a Notice.
                                            </div>
                                        {{/link-to}}
                                        {{else}}
                                        <div class="well text-center no-margin">
                                            No notices...
                                        </div>
                                    {{/unless}}
                                {{/if}}
                            </div>
                        </div>

在上面的代码中,model.result.items具有Violation元素,如何显示显示的novv.ViolationNumber的novi.itemNum,请提供任何帮助-预先感谢。

javascript ember.js
1个回答
0
投票

[您的问题还不是100%清楚,但是我认为您正在寻找按值(model.result.items)过滤一个集合(novv.ViolationNumber)。在这种情况下,您可以使用ember-composable-helpers#find-by

<td>
  {{#with (find-by 'ViolationNumber' novv.ViolationNumber model.result.items) as |item|}}
    {{log item}}
  {{/with}}
</td>
© www.soinside.com 2019 - 2024. All rights reserved.