0

I'm trying to bind a var which contains an URL and ng-click.

I'm binding this url - but it doesn't show as a hyperlink.

var myURL = "http://www.cnn.com');'>LINK"

it appears literally ... like

<a ng-click='formatter.GotoLink('http://www.cnn.com');'>LINK</a>

instead of just "LINK"

Any ideas what's wrong with myURL string?

formatter.GotoLink = function (url){
    window.open(link,'_system');
}
1
  • 1
    You have a ' quote mismatch. Use " as outer quotes for your HTML attributes Commented May 6, 2015 at 13:15

2 Answers 2

3

First, wrap your expression between double quotes

<a ng-click="formatter.GotoLink('http://www.cnn.com');">LINK</a>

Then make sure your function uses the right param (url or link)

formatter.GotoLink = function (url){
    window.open(url,'_system');
}

Finally, for a link to show as an hyperlink, you need an href. You could do this (if you don't need the window object):

<a ng-href="http://www.cnn.com" target="_system">LINK</a>
Sign up to request clarification or add additional context in comments.

Comments

1
<a ng-click="formatter.GotoLink('http://www.cnn.com')">LINK</a>

7 Comments

How do I build the string.
var arrOfDocs = []; arrOfDocs.push("<a ng-click="formatter.GotoLink('cnn.com');">LINK</a>"); this doesn't work
why are you using an array to build a string?
The links come from a JSON file - I need to build an array of hyperlinks that then can be displayed (binding) and clicked on
String website = "cnn.com";String link = "<a ng-click='formatter.GotoLink(Website)'>LINK</a>"; Push this link into your array
|

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.