im using a if statement in my handlebars template. the if statement works, but when you try change the route it causes a Uncaught TypeError: Cannot call method 'unchain' of undefined.
i have recreated the error in the following jsbin
demo : http://emberjs.jsbin.com/UnUVorUn/9
code : http://emberjs.jsbin.com/UnUVorUn/9/edit
Your problem happens because your IsLink
starts with a capital letter, there was a bug when used in a handlebars template, already fixed in 1.3.0. But if you update your ember version you will have a new problem, because ember consider a property that starts with a capital letter being a global path, so instead of sectionController.IsLink
, it will lookup window.IsLink = 'teste'
.
I recommend you to just update to isLink
to avoid these problems:
App.SectionController = Ember.Controller.extend({
isLink :Ember.computed.equal('model.type', 'link')
});
Template
<ul>
{{#link-to 'index'}} index{{/link-to}}
{{#link-to 'test'}} test{{/link-to}}
{{#each model itemController="section"}}
{{#if isLink}}
<li>{{model.color}}</li>
{{/if}}
{{/each}}
</ul>
http://emberjs.jsbin.com/UnUVorUn/12/edit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With