Issue
I'm passing a query string to a function, which 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?
Solution
why do you $compile the URL, I don't see why this would be needed. $compile in angular does not compile URLs, it compiles an HTML-String or a DOM-tree and compiles/links angular directives that are used in this HTML.
Is this solving your issue?
in the controller:
$scope.myUrl = "http://... ";
in the HTML:
<a ng-href="{{myUrl}}" target="_blank">blabla</a>
Answered By - Reto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.