ey dee ey em
ey dee ey em

Reputation: 8593

AngularJS Ternary Expression not valid

{{var.a != "N/A" ? "<a ng-href='myapp://find?name="+var.a+"'>"+'var.a'+"</a>" :var.a}}

My ternary operator in this format for angularjs seems not working (in the view, ternary result is not showing but the exact written code above show in the view). I wonder where is the mistake as no error is returned on anywhere in chrome inspector.

I use Angularjs 1.2.2

Even way to troubleshoot it will really help.

Thank you

Upvotes: 0

Views: 594

Answers (1)

Denis C de Azevedo
Denis C de Azevedo

Reputation: 6298

Why don't you use:

<a ng-href="myapp://find?name={{var.var1}}" ng-show="var.var1 != 'N/A'">{{var.var1}}</a>
<span ng-hide="var.var1 != 'N/A'">{{var.var1}}</span>

You can also use ng-switch.

Upvotes: 3

Related Questions