Availability of the following user model:
Sks.User = DS.Model.extend
firstName: DS.attr("string")
lastName: DS.attr("string")
where should the computed property 'fullName' be declared?
fullName: Ember.computed(->
firstName = @get("firstName")
lastName = @get("lastName")
firstName = "" if firstName is `undefined`
lastName = "" if lastName is `undefined`
lastName + " " + firstName
).property("firstName", "lastName")
Should it be in the "UserController" or directly in the model? The Ember documentation says that fields used only in a session should be written to controllers. But the problem is that I could not access the "fullName" in the Index template:
Sks.IndexController = Ember.Controller.extend
needs: ['users']
Here 'fullName' was unavailable (declared in the controller)
{{#each user in controllers.users}}
<li>{{user.fullName}}</li>
{{/each}}
But this is when he is in the model.
source
share