Saloni
Saloni

Reputation: 172

How to use expression in ng-href for passing query parameters?

<a ng-href="{{a==3 ? 'www.google.com/correct?{{a}}' : 
'www.google.com/correct?{{a+1}}'}}"

It throws error.

Error: $parse:lexerr Lexer Error

Can anyone help please. I am new to angularjs and learning, not able to figure out how should I proceed.

Upvotes: 0

Views: 298

Answers (1)

briosheje
briosheje

Reputation: 7436

Please use:

ng-href="a===3 ? ('www.google.com/correct?' + a) : ('www.google.com/correct?' + (a+1))"

Since it's an ng-tag, you shouldn't use brackets, and treat it like regular javascript.

Upvotes: 1

Related Questions