How to do a double condition {{#if person && work}} ? The && seems not a valid operator
I don't believe handlebars supports multiple items in the {{#if}} statement (related: Logical operator in a handlebars.js {{#if}} conditional).
You could collapse the multiple values in your controller/view into a single computed property and check that single value in the template. This new computed property will update when either of the original values update:
App.ValuesTestController = Ember.Controller.extend({
value1: false,
value2: true,
value1and2: function(){
return this.get('value1') && this.get('value2');
}.property('value1', 'value2')
});
Your template would look like this:
<div>{{#if value1 }}value 1 true{{/if}}</div>
<div>{{#if value2 }}value 2 true{{/if}}</div>
<div>{{#if value1and2 }}value 1 and 2 true{{/if}}</div>
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