相关疑难解决方法(0)

从组件访问存储

我有一个组件,当用户点击组件它添加一些值存储,我尝试使用这种方式,但我得到一个错误:

OlapApp.MeasureListItemComponent = Ember.Component.extend({
  tagName: 'li',
  isDisabled: false,
  attributeBindings: ['isDisabled:disabled'],
  classBindings: ['isDisabled:MeasureListItemDisabled'],

  actions: {
    add: function(measure) {
      var store = this.get('store');
      store.push('OlapApp.AxisModel', {
            uniqueName: measure.uniqueName,
            name: measure.name,
            hierarchyUniqueName: measure.hierarchyUniqueName,
            type: 'row',
            isMeasure: true,
            orderId: 1
      });
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

这是错误的:

Uncaught TypeError: Cannot call method 'push' of undefined  MeasureListItemComponent.js:18
Run Code Online (Sandbox Code Playgroud)

将记录从组件中存储起来是否可行?为什么我不能进入商店?我的模型名称是'AxisModel',应用程序命名空间是'OlapApp'

ember.js ember-data

49
推荐指数
6
解决办法
3万
查看次数

如何在ember.js中的组件中获取存储

我是如何在一个组件内部处理商店的?我正在尝试创建一个从商店返回结果的自动完成组件.

App.AutoCompleteComponent = Ember.Component.extend({

    //-------------------------------------------
    // Ember Properites
    //-------------------------------------------
    content: Ember.ArrayController.create(),

    //-------------------------------------------
    // Instance Properties
    //-------------------------------------------
    queryText: "",

    componentItemSelected: null,

    //-------------------------------------------
    // Observers
    //-------------------------------------------
    queryTextChanged: function () {
        this.updateContent(this.get("queryText"));
    }.observes("queryText"),

    //-------------------------------------------
    // Instance Methods
    //-------------------------------------------
    selectItem: function (item) {
        this.set("componentItemSelected", item);
    },

    updateContent: function (queryText) {

        if (queryText.length <= 5) {

            console.log('not greater than 5 chars');
            return;
        }

        this.get("content").setObjects([]);

        var items = App.Company.find();

        this.get("content").setObjects(items);
    }
});
Run Code Online (Sandbox Code Playgroud)

这是我的公司模特

App.Company = DS.Model.extend({

  name: DS.attr('string'),

  created_at: DS.attr('date'),

  updated_at: DS.attr('date'),

  people: DS.hasMany('person')

});
Run Code Online (Sandbox Code Playgroud)

我试过了: …

javascript nullreferenceexception ember.js

7
推荐指数
1
解决办法
2903
查看次数