Does ember.js support an ObjectController? If not, what replaces it?

I am trying to learn Ember.js, and although I understand that everything is in motion, and at the moment it seems that this bit of code from the Sproutcore 2 manuals (which are related to Emme.js github readme) no longer works:

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

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

+4
source share
3 answers

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

+4
source

It is planned to return ObjectController / ObjectProxy . Peter and I started working on this here , but we need to add some lower-level features to Ember before it can be fully supported.

Until then, you can use Ember.Object with the content property. You will need to explicitly reference the content property in the property paths (e.g. App.userController.content ). When the ObjectController is complete, you can switch your controllers to inherit from it, and you can update your property paths so as not to explicitly reference the content .

+10
source

Source: https://habr.com/ru/post/1391013/


All Articles