0

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

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

I'm using $sce but left it out. I've updated the code.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.