简体   繁体   中英

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?

您可以使用三元运算符

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

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