Any ideas what I'm doing wrong that the value of revisedprice isn't displaying in the span?
HTML:
<div ng-app="app" ng-controller="ctrl">
<strong><span ng-bind-html="revisedprice"></span></strong>
</div>
Angular:
var app = angular.module('app',[]);
app.controller('ctrl', function($scope, $sce) {
$scope.revisedprice = "<strike>17ドル</strike>";
)};
Example: http://jsfiddle.net/wdf6vkck/2/
asked Jan 1, 2015 at 4:37
4thSpace
44.5k102 gold badges309 silver badges496 bronze badges
1 Answer 1
seems like you didnt add the ng-sanitize js and the dependency.
var app = angular.module('app',['ngSanitize']);
here is the Fiddle
if you use $sce you controller should be like,
app.controller('ctrl', function($scope, $sce) {
$scope.revisedprice = $sce.trustAsHtml("<strike>17ドル</strike>"); // add trustAsHtml()
});
here is the Demo Fiddle
answered Jan 1, 2015 at 4:47
Kalhan
21.9k8 gold badges71 silver badges96 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
4thSpace
I'm using $sce but left it out. I've updated the code.
default