How can I make ternary operator work if I have the following codes?
'<p>{balance==0?<span class="danger">Not available</span>:(Stock: {balance}})</p>'
Thank you!
Sorry about that, maybe my question is not clear. Let me elaborate more here I'm using Bloodhound library to provide a suggestion drop down list. And the code as shown as below.
var prodName_typehead = {
name: 'prod_name',
displayKey: 'name',
hint: (App.isRTL() ? false : true),
source: item.ttAdapter(),
limit: 20,
templates: {
suggestion: Handlebars.compile([
'<div class="media">',
'<div class="pull-left">',
'<div class="media-object">',
'<img src="{{thumb}}" width="50" height="50"/>',
'</div>',
'</div>',
'<div class="media-body">',
'<p><strong>{{name}}</strong></p>',
'<p>{{desc}}</p>',
`<p>${balance==0 ? `<span class="danger">Not available</span>`:`(Stock: ${balance})`}</p>`,
'</div>',
'</div>',
].join(''))
}
};