Hi,
I want to register an Em Helper that I can use like this
{{#if (equal a b)}}hello world{{/if}}
I am not using Ember CLI I just want to do it w/in the browser like this:
App.equalHelper = Em.Helper.extend({
compute: function(params, hash) {
return Em.isEqual(params[0], params[1]);
}
});
This produces an error:
Uncaught TypeError: Cannot read property ‘isLegacyViewHelper’ of
undefined
Can sb point me the correct syntax? I use Ember 2.
Hmm, I’m not sure if the globals resolver even supports helpers. You may have to register the helper manually. Also, you want to use at least two word (dasherized) names for your helpers. Example:
App.register('helper:is-equal', Ember.Helper.helper(function(params) {
return params[0] === params[1];
}));
Here is a JSBin: JS Bin - Collaborative JavaScript Debugging
EDIT:
Okay, rooting around through the DefaultResolver it looks like I was wrong. You should be able to just do:
App.IsEqualHelper = Ember.Helper.helper(function(params) {
return params[0] === params[1];
});
Here is an updated that JSBin: JS Bin - Collaborative JavaScript Debugging
1 Like
Thanks!!
I am sure Ember is still pretty much the same w/ CLI and non-CLI versions.