0
<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.

6
  • This syntax is invalid. What are you trying to accomplish? Commented Sep 12, 2018 at 10:36
  • @briosheje If the condition is satisfied it should redirect to link1 else to link2. Commented Sep 12, 2018 at 10:38
  • @briosheje Please check this: stackoverflow.com/questions/32595829/… But I want to pass query parameters in the url. Commented Sep 12, 2018 at 10:39
  • 1
    use ng-href="a===3 ? ('www.google.com/correct?' + a) : ('www.google.com/correct?' + (a+1))" Commented Sep 12, 2018 at 12:16
  • Thank you so much @briosheje. It worked perfectly. :) Commented Sep 12, 2018 at 12:34

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.