【问题标题】:Ember.Select in emblemjsEmber.Select 在会徽js
【发布时间】:2015-09-24 18:25:00
【问题描述】:

我正在尝试在我的模板中使用Ember.SelectEmber.Select 没有任何属性 |特性。但是当我指定一个属性内容时,它会给我错误

Uncaught Error: assertion failed: an Ember.CollectionView's content must implement Ember.Array. You passed countries

我的徽章模板如下,

Ember.Select     // Works fine
Ember.Select content=countries //Gives the listed error

App.IndexController 中的代码是,

countries : function () {
    return ["India","US","England"]; // I have also tried passing the value in Ember.A(array_val)
}.property('')

【问题讨论】:

    标签: ember.js emblem.js


    【解决方案1】:

    我不熟悉 Emblem,但首先,可能值得尝试根据 API documentation 创建一个选择并将 countries 定义为文字数组。

    countries : ["India","US","England"],
    

    但是我认为您的问题是您将其定义为 .property('') 什么都没有。如果您不想重命名您的属性,只需将其设置为:.property(),或者如果您想将其命名为不同的名称.property('countriesCollection')。这将允许您在模板中使用countriesCollection

    您还应该查看computed properties,因为大概您想对您的数组做一些事情(否则它也可能是一个文字数组)。

    另一方面,Ember 1.13 具有deprecated 视图,因此您实际上应该转向组件驱动的方法,而不是使用视图和控制器。有一个很好的 select 组件,称为 x-select,它与 Ember.Select 视图 API 兼容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多