我有以下工作車把代碼的前兩個條目:遍歷的枚舉
{{#each phoneNumber in switchboardEntry.sipAccount.phoneNumbers}}
<span class="label">
{{phoneNumber.number}}
</span>
{{/each}}
但我想循環剛的switchboardEntry.sipAccount.phoneNumbers
前兩個項目,而不是通過配套。我在http://emberjs.com/guides/enumerables/上找到了一個過濾器示例,但仍然處於Ruby思維模式下,我試圖在switchboardEntry.sipAccount.phoneNumbers
之後放置該過濾器,但這不起作用。
解決此問題的最佳方法是什麼?
你就不能使用'switchboardEntry.sipAccount.phoneNumbers [0]'和'switchboardEntry.sipAccount.phoneNumbers [1]'在這種情況下? – 2013-04-04 09:21:25
@FinnMacCool這樣做並不那麼靈活,如果他稍後想要列表中的3或4個項目。也重複的代碼:) – mbogh 2013-04-04 09:29:08
是啊,如果他打算稍後改變它,你的解決方案肯定會更好。 – 2013-04-04 09:32:36