ember.js - Getting an Ember controller's function property from inside an Ember Handlebars template -
in ember handlebars template, possible access controller's (string/boolean/number based) property using
{{someproperty}}
<somehtmltag {{bindattr somehtmltagattribute="someproperty" />
constructs.
this doesn't seem work function-based controller properties.
example
the following works
//handlebars <script type="text/x-handlebars" id="index"> property: {{someproperty}}<br/> </script> //javascript app.indexcontroller = ember.objectcontroller.extend({ someproperty: "yolo", });
the following doesn't work
//handlebars <script type="text/x-handlebars" id="index"> property: {{someproperty}}<br/> </script> //javascript app.indexcontroller = ember.objectcontroller.extend({ someproperty: function() { return "yolo"; }, });
using {{bindattr ...}}
gives little insight problem:
uncaught error: assertion failed: attributes must numbers, strings or booleans, not function () ...{
how can access function-based ember controller properties within handlebars template?
if need function executed when property accessed, like:
//javascript app.indexcontroller = ember.objectcontroller.extend({ someproperty: function() { // stuff... return "yolo"; }.property() });
working fiddle
hope helps
Comments
Post a Comment