Reputation: 8189
I have the following controller:
Whistlr.OrganizationController = Ember.ObjectController.extend
location: (->
location = this.city+", "+this.country
return location
)
And this in my template:
{{location}}
But rather than rendering a string such as "New York, USA", ember renders:
function () { var location; location = this.city + ", " + this.country; return location; }
What am I doing wrong here?
Upvotes: 1
Views: 145
Reputation: 10077
You forgot to define it as a Computed Property:
Whistlr.OrganizationController = Ember.ObjectController.extend
location: (->
location = this.get('city') + ", " + this.get('country')
return location
).property('city', 'country')
Don't forget to use get()
when you use the value of a property. In other words, use this.get('foo')
, not this.foo
. Also, since you use CoffeeScript your code is better written as:
Whistlr.OrganizationController = Ember.ObjectController.extend
location: ( ->
@get('city') + ", " + @get('country')
).property('city', 'country')
Upvotes: 2