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

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -