简体   繁体   中英

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM