ember.js是否仍然支持ObjectController?如果没有,什么替代它? [英] Does ember.js still support ObjectController? If not, what replaces it?

查看:108
本文介绍了ember.js是否仍然支持ObjectController?如果没有,什么替代它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习一些Ember.js,而我意识到一切都在变化,而且这一刻,似乎来自Sproutcore 2指南(这些链接到Ember.js github自述文件)的这一段代码,不再工作:

  App.userController = SC.ObjectController.create({
content:SC。 Object.create({
firstName:Albert,
lastName:Hofmann,
posts:25,
hobbies:骑自行车
})
});

查看ember.js源代码,似乎支持的唯一控制器类型是arryay控制器。在不是数组/集合和视图的一部分的单一模型对象之间是否存在一个确定的最佳做法?或者人们放弃代理,并直接在模型和查看对象之间建立绑定?想法?

解决方案

更新:是, Ember.ObjectController 是第一个 - Ember的一部分,最常用于代理模型的属性,以便通过模板轻松呈现。请参阅 http://emberjs.com/api/classes/Ember.ObjectController.html用于文档。


I'm trying to learn some Ember.js and while I realize everything is in flux and the moment, it seems that this bit of code from the Sproutcore 2 guides (which are linked to at the Ember.js github readme) doesn't work any longer:

   App.userController = SC.ObjectController.create({
        content: SC.Object.create({
        firstName: "Albert",
        lastName: "Hofmann",
        posts: 25,
        hobbies: "Riding bicycles"
      })
    });

Looking at the ember.js source, the only type of controller that seems to be supported is an arryay controller. Is there an established best practice for proxying between a single model object that is not part of an array/collection and a view? Or do people forego the proxying and simply set up bindings directly between the model and view objects? Thoughts?

解决方案

UPDATED: Yes, Ember.ObjectController is a first-class part of Ember and is most frequently used to proxy a model's properties for easy rendering by templates. See http://emberjs.com/api/classes/Ember.ObjectController.html for documentation.

这篇关于ember.js是否仍然支持ObjectController?如果没有,什么替代它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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