Angular not rendering html, putting "unsafe" in my URLs

3,685 views
Skip to first unread message

gr...@gregburger.com

unread,
Feb 28, 2013, 7:55:21 PM2/28/13
to ang...@googlegroups.com
Hi, I'm new to Angular and ran into a couple issues with Angular being a bit "heavy handed" with trying to "keep me safe".

In a controller, if I set a model equal to a string that contains HTML, like this:
$scope.test1 = "This &amp; <a href="#">that</a>.";

The in the view I use {{test1}}, the HTML elements are printed rather than being treated as HTML... "&" become "&amp;" and "<" becomes "&lt;", etc.

Also, I have an ng-repeat directive where one of the elements being repeated is a "vnc" link:

<tr ng-repeat="device in devices">
<td>...</td>
<td>...</td>
<td><a href="vnc://{{device.ip}}">vnc</a></td>
</tr>

And on the page, all the links have "unsafe:" added to the beginning. Like: <a href="unsafe:vnc://123.123.123.123">

How can I turn these things off? I can't find any reference to these in the docs.

Thanks,
Greg


Clint Checketts

unread,
Feb 28, 2013, 11:38:27 PM2/28/13
to ang...@googlegroups.com
Greg,


app.config(function($compileProvider){
  $compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);
});




--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages