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"; }, }); 

here jsfiddle


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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -