JavaScript runtime error: [$parse:lexerr]

Hi..
I'm passing a querystring to a function - which then gets $compiled that opens a new window.
I get the following error

- JavaScript runtime error: [$parse:lexerr] Lexer Error: Unexpected next character  at columns 128-128 [&]

var url = 'http://.....?&filename=123.doc&user=Bob'

var html = <a href='#' ng-click='OpenUrl(" + url + ")'>MY LINK </a>"

var link =  $compile(html)($scope)


the function just opens a new window .  It doesn't seem to like the '&'

I'm $compiling the url and expression so it can be used in an ng-click

Any ideas what I'm doing wrong?
LVL 1
JElsterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:
I don't know if you just mistyped but you have a missing double-quote (really after the var html=) and you're also missing the semi-colon at the end of this line:
var html = "<a href='#' ng-click='OpenUrl(" + url + ")'>MY LINK </a>";

Open in new window

This might explain the unexpected & because it's not withing quotes
0
JElsterAuthor Commented:
I miss typed the question. I have the double-quite
the code run.. but get that error on the $compile
0
Alexandre SimõesManager / Technology SpecialistCommented:
Anyway, if it's only to open a new window, why don't you use a simple target="_blank" in the link?
"<a href='" + url + "' target="_blank">MY LINK </a>"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JElsterAuthor Commented:
I need to pass it to a function that add SSO to the request and makes an HTTP call
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.