javascript - Can I use a ternary operator with angularjs outside of the class attribute? -
i'm looping through json object angularjs, , having trouble dealing nulls.
i'm new angular.
<a href="#" data-mycustom="{{product.related}}">...</a>
in event of related being null:
{ "related":null }
i want put "-1" in place:
<a href="#" data-mycustom="-1">...</a>
tried ternary operator isn't evaluating... it's displaying plain text.
simply use ng-attr
add custom attribute after evaluation of {{}}
interpolation directive
markup
<a href="#" ng-attr-data-mycustom="{{product.related || '-1' }}">...</a>
Comments
Post a Comment