0
我有一個複選框選擇的數據表。如果表格中的項目被選中,我想在頁面的另一部分顯示該數據。似乎應該很簡單,但我似乎無法弄清楚。我做了一個jsEmberjs:使用複選框顯示數據
JS Bin with data table example
這裏是控制器/路由
App.IndexController = Ember.Controller.extend({
productLinks: function(){
return this.get('content');
}.property('model', 'isSelected'),
selectedProduct: function(){
var selectedProd = this.get('productLinks').filterBy('isSelected', true);
return selectedProd[0];
}.property('isSelected'),
isSelected: null
});
我想這個進化到只允許一個單一的選擇,但我會解決,一旦我能得到要顯示的數據。
太好了!非常感謝,我知道它不應該那麼難 – Bungdaddy 2014-09-29 04:02:08
從技術上講,你可以省略第二個參數到'filterBy'。但是,您可以使用'findBy'來查找第一個選定的元素,因此整個函數體就變成了'return this.get('productLinks')。findBy('isSelected');'。 – 2014-09-29 06:13:54