Ember getting content from another controller doesn't work with local storage adapter

泪湿孤枕 提交于 2019-12-11 17:58:21

问题


Getting content from another controller via this.get("controllers.index.content") or this.get("controllers.index.arrangedContent") (for sorted content) doesn't work when using the ember-localstorage-adapter on the backend.
For example, getting content from another controller:

App.StartController = Ember.ObjectController.extend({
needs: 'index',
someFunction: function() {
    // get the "content" from the IndexController
    var names = this.get("controllers.index.arrangedContent");
    alert(names.objectAt(0).name); // should display the name property from
first stored object(if there are any stored in local storage of course),
instead, it always returns "undefined"
}
});

What am I doing wrong here? Here's an example jsfiddle


回答1:


same problem as in Ember loop through content of controller

you have to use

alert(names.objectAt(0).get('name'));


来源:https://stackoverflow.com/questions/17065647/ember-getting-content-from-another-controller-doesnt-work-with-local-storage-ad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!