0

Consider the following:

<span ng-bind-html="product.icon"></span>

If product.icon contains:

<img src="http://localhost/angularjs/public/gfx/product/logo_1.png" width="18" height="18">

It will display fine. However, if it contains:

<img src="http://localhost/angularjs/public/gfx/product/logo_1.png" style="width: 18px; height: 18px">

Then width and height are not respected.

Why this behavior? Is it because of : or ; from the inline style?

3

1 Answer 1

1

In this case, it was not enough to use ng-bind-html, I had to combine it with this filter:

angular.module('myApp')
    .filter('to_trusted', ['$sce', function($sce){
        return function(text) {
            return $sce.trustAsHtml(text);
        };
    }]);

Now using <span ng-bind-html="product.logo_and_name | to_trusted"></span> the inline css is respected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.