0
我有一個「Candidato」列表,我想在下拉框中顯示。這裏有一個Candidato的例子:Ember.Select條件值optionLabelPath
{"id": 3, "nombre": "Ivonne Álvarez Garcia", "sexo": 0, "confirmado": true}
這裏的另一個問題:
{"id": 1, "nombre": "Margarita Arellanes Cervantes", "sexo": 0, "confirmado": false},
在我的模板我有這樣的:
{{view "select" content=model.candidatosPAN optionValuePath="content.id" optionLabelPath="content.nombre" selection=newParams.candidatoPAN}}<br/>
的事情是我想要的「選項標籤」來可變,取決於nombre和confirmado。因此,例如,Ivonne的選項將顯示爲「IvonneÁlvarezGarcia(*)」...因爲她是「confirmmado」。另一方面,瑪格麗塔的選擇是:「Margarita Arellanes Cervantes」,因爲她不是「confirmmado」。
什麼是最簡單和最簡單的方法來做到這一點?
謝謝!
嗨,我也考慮過這種方法。然而,由於所選選項被綁定的方式(它直接與底層模型綁定),我不得不使用從路由模型中提取的原始候選選項。 有沒有涉及定義Ember.Select的簡單擴展的方法? – 2015-02-06 20:45:33
如果您想直接更新模型,可以將觀察者添加到控制器,觀察選定的ID。在觀察員中,您必須找到正確的候選人並與候選人更新模型。 – jcbvm 2015-02-06 20:50:49
啊!對。感謝您指出了這一點。 – 2015-02-06 20:52:16