評估在車把兩個條件我想知道,如果它能夠做這樣的事情:使用燼
{{#if ClientController.Client.number && PhoneController.hasLinesToInstall}}
...
{{/if}}}
感謝,
Juanitos
評估在車把兩個條件我想知道,如果它能夠做這樣的事情:使用燼
{{#if ClientController.Client.number && PhoneController.hasLinesToInstall}}
...
{{/if}}}
感謝,
Juanitos
我不認爲這是可能的鏈條條件就像那樣的把手 - 在文檔中找不到任何關於它的東西。
,你可以窩他們雖然是這樣的:
{{#if ClientController.Client.number}}
{{#if PhoneController.hasLinesToInstall}}
...
{{/if}}
{{/if}}
這將實現相同的效果。
它不支持外的開箱,但你可以使用插件https://github.com/jmurphyau/ember-truth-helpers:
ember install ember-truth-helpers
然後,在你的模板:
{{#if (and ClientController.Client.number PhoneController.hasLinesToInstall)}}
...
{{/if}}}
此前,社會各界的理解是,模板應該基本上沒有邏輯。加班時,我們的觀點已經轉向在模板中放置更多的聲明性邏輯 - ember-truth-helpers
,ember-composable-helpers就是一個很好的例子。
工作對我來說這樣的:
Ember.computed.and('firstComputedProperty', 'secondComputedProperty')
此其我的備份解決方案,但由於任何方式。 –
@Juanito - 我一直在做一些更多的閱讀,我發現有幾個人說,它***並非***可能,它是一個設計功能的把手(迫使你保持你的模板乾淨並且沒有屬於別處的邏輯)。 http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional#comment-11152800 http://blog.teamtreehouse.com/handlebars-js-part-2-partials - 幫助 – Anonymous
感謝您的幫助;) –