Re: [angular.js] Outputting raw HTML in templates

12,476 views
Skip to first unread message

Pawel Kozlowski

unread,
Jul 15, 2012, 3:19:01 PM7/15/12
to ang...@googlegroups.com
hi1

On Sun, Jul 15, 2012 at 8:52 PM, Victor Stan <victo...@gmail.com> wrote:
>
> Is it possible (and how) to output raw HTML in templates? so if I have
> something like {{data.html}} I could get unescaped html out some way? Is
> there a prefix? I know mustache uses tripple brackets for raw html
> {{{data.html}}}.

You might be looking for the ng-bind-html
(http://docs.angularjs.org/api/ngSanitize.directive:ngBindHtml), here
is the jsFiddle:
http://jsfiddle.net/pkozlowski_opensource/Hd4t4/1/

ng-bind-html is defined in a separate module and a separate file so
don't forget:
1) include the http://code.angularjs.org/1.0.1/angular-sanitize-1.0.1.js
2) declare dependency on the ngSanitize module:
angular.module('myApp',['ngSanitize'])

Hope this helps,
Pawel

Social

unread,
Sep 27, 2013, 12:07:40 PM9/27/13
to ang...@googlegroups.com
It's problem, but 

<tr ng-repeat="obj in currencies">
    <td  ng-bind-html-unsafe="obj.status">{{obj.status}}</td> ...  
is working in older angularjs ver 1.0.8, that output as HTML, 
 but it's do'nt working in v1.2.0-rc.2   :((((((((((((((((((((  output as  <span class='label label-success'>&nbsp;3&nbsp;</span>



Why ??????????????????


воскресенье, 15 июля 2012 г., 21:52:45 UTC+3 пользователь Victor Stan написал:
Hi,

Lulzim Bilali

unread,
Sep 27, 2013, 2:18:13 PM9/27/13
to ang...@googlegroups.com
I think in 1.2 you have to use ngBindHtml. Do not forget to include ngSanitize
http://docs.angularjs.org/api/ng.directive:ngBindHtml
Reply all
Reply to author
Forward
0 new messages