I'm trying to pass my controller value in customized Handlebars if condition helper. But I am not able to get the value inside my helper
I am updating my controller.scope value, which comes from my ajax response. Scope will be differ upon the need as 0,1,2,3.
In my hbs,
{{#ifCond controller.scope '==' '0'}}
//Doing something here.
{{/ifCond}}
{{#ifCond controller.scope '==' '1'}}
//Doing something here.
{{/ifCond}}
{{#ifCond controller.scope '==' '2'}}
//Doing something here.
{{/ifCond}}
{{#ifCond controller.scope '==' '3'}}
//Doing something here.
{{/ifCond}}
In my helper class,
Ember.Handlebars.registerHelper('ifCond', function (temp_v1, operator, temp_v2, options) { // No I18N
var v1,v2;
v1 = Ember.Handlebars.get(this, temp_v1, options);
v2 = Ember.Handlebars.get(this, temp_v2, options);
if( v1 == undefined ){
v1 = temp_v1;
}
if( v2 == undefined ){
v2 = temp_v2;
}
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
});
console.log(v1); // It prints 'scope', but need like '0' or '1' or '2' or '3'.
My console prints always the raw value of v1, but I need the evaluate value of v1.
How to do this?