When playing with ember, I found that sometimes the model is stored in the controller property content, sometimes the model is also available directly on the controller. However, I do not understand when this happens.
Let me explain this with the example I found when building my ember MVC.
Setting A - Start
- I defined a user object
Membercorresponding to MemberRoute, MemberViewclasses and template name Member. - The object
Memberhad some attributes, such as id, nicknameetc. - NOTE : the form controller has not been defined
MemberController, therefore, by agreement of ember, he himself provides the controller.
Setting B - Setting
- Same as installing A, but now there is
MemberControllerone that contains some action methods that run from the template.
Strange behavior (accordingly, what I do not quite understand)
- in setting A, I can directly refer to attributes
Memberwith {{id}}or {{nickname}}. - in setting B, I have to use
{{content.id}}or{{content.nickname}}
As stated in the ember documentation MemberViewdoes
setupController : function(controller, member) {
controller.set('content', member);
},
So can someone help me understand why the difference is and where is the difference? I am currently assuming that it will be
- that the context of the template is different (maybe there is a piece of code missing in the controller configuration?)
or
- The default controller provided by ember automatically has additional magic that may not be available for custom controllers.
, , . , . , , requireJS (, , ). Ember - v1.0pre4.
!