灰烬从另一个控制器获取内容不适用于本地存储适配器 [英] Ember getting content from another controller doesn't work with local storage adapter

查看:52
本文介绍了灰烬从另一个控制器获取内容不适用于本地存储适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 this.get("controllers.index.content") this.get("controllers.index.arrangedContent")从另一个控制器获取内容排序的内容)在后端使用ember-localstorage-adapter时不起作用.
例如,从另一个控制器获取内容:

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"
}
});

我在这里做错了什么?这是一个示例 jsfiddle

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

推荐答案

Ember遍历控制器的内容

您必须使用

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

这篇关于灰烬从另一个控制器获取内容不适用于本地存储适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆