Search code examples
angularjsanchorangularjs-ng-href

AngualrJs - change value of href in link -


I can change properties in AngularJS by using a conditional If statement:

OrgName: org && org.id==4162 ? 'Org1' : 'Org2'

But i want to be able to change the href of a link depending on this value. How can I accomplish this? I have tried:

<a org && org.id==4162 ? ng-href=https://www.org1.com/ : ng-href=https://www.org2.com/>Org Link</a> 

Any help appreciated?


Solution

  • you can use ternary operator

    <a  ng-href="{{org && org.id==4162 ? 'https://www.org1.com/':'https://www.org2.com/' }} ">Org Link</a>