Paolo B
Paolo B

Reputation: 3354

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?

Upvotes: 0

Views: 31

Answers (1)

Chellappan வ
Chellappan வ

Reputation: 27293

you can use ternary operator

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

Upvotes: 1

Related Questions