angularjs - $sce.trustAsHtml not working -
alright, following below i've tested in code works:
javascript:
var string = '<p>hello</p>'; $scope.html = $sce.trustashtml(string);
html:
<span ng-bind-html="html"></span>
the thing i'm trying this: pulling bunch of items server in json form. 1 of json's key called "description", long string of html code.
i'm pushing these items $scope array can show them on page through ng-repeat directive. code below summarizes how it's being done:
javascript:
$.getjson('someurl', function(data) { $scope.items = []; (var = 0; < data.count; i++) { var item = {}; item.description = $sce.trustashtml(data.item[i].description); $scope.items.push(item); } });
html:
<p ng-repeat="item in items"> <span ng-bind-html="item.description"></div> </p>
this isn't producing output reason. read whatever variable bind $sce.trustashtml() must $scope variable. in case, i'm setting regular variable "item.description" , adding $scope.item array.
i suspect may why it's not working, don't know how go fixing it.
can this?
thanks!
try <span ng-bind-html="'{{item.description}}'"></div>
.
something worked me.
Comments
Post a Comment