0
{{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

2
  • What are all the . doing? Are you trying to concatenate those strings and variables (like in PHP)? If so, use + in JavaScript Commented Oct 29, 2014 at 18:43
  • @Ian Did that, but still the same... Commented Oct 29, 2014 at 18:47

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.