如何在 `hbs` 模板中添加带有 `index` 的数字
How to add the number with `index` in `hbs` template
我正在尝试将一个数字添加到现有 index
值,但出现错误。如何解决?
这是我的尝试:tabindex="{{index+1}}"
和 class="digit{{index+1}}"
都抛出错误。
{{#each cardDigitField as |field index|}}
<input type="number" tabindex="{{index+1}}" min="0" max="9" maxlength="1" value=''
onKeyUp={{action "numberEntered" index}}
onKeyPress={{action "numberInit" }} class="digit{{index+1}}">
{{/each}}
您可以从 Angular 了解模板表达式,但默认情况下 Ember 不支持模板表达式。
您可以做的是使用 Ember 模板助手。
要么你create your own or use an addon (for example ember-composable-helpers).
{{#each cardDigitField as |field index| }}
<input type="number" tabindex="{{inc index}}" min="0" max="9" maxlength="1" value=''
onKeyUp={{action "numberEntered" index}}
onKeyPress={{action "numberInit" }} class="digit{{inc index}}">
{{/each}}
我正在尝试将一个数字添加到现有 index
值,但出现错误。如何解决?
这是我的尝试:tabindex="{{index+1}}"
和 class="digit{{index+1}}"
都抛出错误。
{{#each cardDigitField as |field index|}}
<input type="number" tabindex="{{index+1}}" min="0" max="9" maxlength="1" value=''
onKeyUp={{action "numberEntered" index}}
onKeyPress={{action "numberInit" }} class="digit{{index+1}}">
{{/each}}
您可以从 Angular 了解模板表达式,但默认情况下 Ember 不支持模板表达式。 您可以做的是使用 Ember 模板助手。
要么你create your own or use an addon (for example ember-composable-helpers).
{{#each cardDigitField as |field index| }}
<input type="number" tabindex="{{inc index}}" min="0" max="9" maxlength="1" value=''
onKeyUp={{action "numberEntered" index}}
onKeyPress={{action "numberInit" }} class="digit{{inc index}}">
{{/each}}