3

So I am wondering how to compute HTML in an AngularJS object (Like this: {{names}}) but I have an '<a>' element inside the object.

It comes out like this:

<a href="http://www.example.com">link text</a>

I want this: link text
I want the links in this page to be the ones.

4
  • But I wanted that link to work. Commented Feb 2, 2016 at 22:55
  • am I not understanding your question correctly? i'll take the easy route first, <a href="whatever">{{names}}</a> ? Commented Feb 2, 2016 at 23:16
  • @Sixtysixpointsixty-four No, you want us to read the code you expect to generate. Commented Feb 3, 2016 at 14:20
  • When is say <a href="example.com">link text</a> I mean the output was that. Commented Feb 3, 2016 at 20:18

2 Answers 2

3

Im pretty sure the answer you are looking for can be found here ng-href will allow you to use the {{}} syntax to dynamically generate a url from your angular controller.

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

4 Comments

No I need it to generate a link.
Sorry I guess I don't understand what you are asking then, can you please clarify what exactly you are trying to do?
Ok I added a link to a page containing my progress.
Right under the example link under my example code.
0

I think you need something like this <div ng-bind-html="name"></div>.

Note: you may need to do an '$sce.trustAsHtml()' if your HTML contents contain links. But be sure that what content goes in the HTML is safe before doing this. See more details Here

Comments

Your Answer

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