如何在 ember JS 中形成 Table 时使用 #if 使用多个条件?
How to use multiple conditions using #if while forming a Table in ember JS?
我正在使用 Ember
动态形成 Table
如何在形成 table
时使用嵌套 if
像这样
{{#if ismorethanone && model.hasSize}}
<td> Hai </td>
{{else}}
<td> Bye </td>
{{/if}}
我的代码
<script type="text/x-handlebars" data-template-name="index">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Participant</th>
</tr>
</thead>
<tbody id="ParticipantList">
{{#each person in model}}
<tr>
<td> {{person.name}}</td>
<td> {{person.city}}</td>
{{#if ismorethanone}}
<td><img src="image.jpg" alt="Remove" {{action "removeUser" person.name}}></td>
{{/if}}
</tr>
{{/each}}
</tbody>
</table>
</script>
或者使用 ember-truth-helpers
:
{{#if (and ismorethanone && model.hasSize)}}
foo
{{else}}
bar
{{/if}
或者只是嵌套 if
s:
{{#if foo}}
{{#if bar}}
one
{{else}}
two
{{/if}}
{{/if}}
我正在使用 Ember
动态形成 Table如何在形成 table
时使用嵌套 if像这样
{{#if ismorethanone && model.hasSize}}
<td> Hai </td>
{{else}}
<td> Bye </td>
{{/if}}
我的代码
<script type="text/x-handlebars" data-template-name="index">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Participant</th>
</tr>
</thead>
<tbody id="ParticipantList">
{{#each person in model}}
<tr>
<td> {{person.name}}</td>
<td> {{person.city}}</td>
{{#if ismorethanone}}
<td><img src="image.jpg" alt="Remove" {{action "removeUser" person.name}}></td>
{{/if}}
</tr>
{{/each}}
</tbody>
</table>
</script>
或者使用 ember-truth-helpers
:
{{#if (and ismorethanone && model.hasSize)}}
foo
{{else}}
bar
{{/if}
或者只是嵌套 if
s:
{{#if foo}}
{{#if bar}}
one
{{else}}
two
{{/if}}
{{/if}}