开发者

PURE use default value

开发者 https://www.devze.com 2023-03-21 18:51 出处:网络
I\'m using PURE from BeeBole for filling some HT开发者_开发百科ML templates with JSON, everything works perfect except that I can\'t find how to pass a default value when a missing property, and I wan

I'm using PURE from BeeBole for filling some HT开发者_开发百科ML templates with JSON, everything works perfect except that I can't find how to pass a default value when a missing property, and I wanted to do this from this side since from the server there is nothing I can do. So for example I have this JSON object:

var example = {records: [ {id: '1', name: 'Bill', nick: 'B'}, {id: '2', name: 'Amy'} ]}

When I render this in a table, on the directive when I ask for 'nick' I get 'B' for the first and nothing for the second, but for this case I would like to set a default value such as '-' when the property is not found.

Is this possible?

Thank you


A bit late on this one. If you want to show the nick in a SPAN, it should look something like:

'span':function(){
  return this.nick || '-';
}

instead of:

'span':'nick'

You would probably get a quicker answer on the forum

0

精彩评论

暂无评论...
验证码 换一张
取 消