Ember.js controller method is returning the function as text -


i have following controller:

whistlr.organizationcontroller = ember.objectcontroller.extend   location: (->     location = this.city+", "+this.country     return location   ) 

and in template:

{{location}} 

but rather rendering string such "new york, usa", ember renders:

function () { var location; location = this.city + ", " + this.country; return location; } 

what doing wrong here?

you forgot define computed property:

whistlr.organizationcontroller = ember.objectcontroller.extend   location: (->     location = this.get('city') + ", " + this.get('country')     return location   ).property('city', 'country') 

don't forget use get() when use value of property. in other words, use this.get('foo'), not this.foo. also, since use coffeescript code better written as:

whistlr.organizationcontroller = ember.objectcontroller.extend   location: ( ->    @get('city') + ", " + @get('country')   ).property('city', 'country') 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -