Web Develop Wolf
Web Develop Wolf

Reputation: 6326

ngSanitize still displaying text instead of HTML

I have a few items on the AngularJS scope that I want to see as HTML, I've found that ngSanitize needs to be added to the app to do this. So I added this to the declaration on the index page:

<script src="Scripts/angular-sanitize.min.js"></script>

And included this in the app

var app = angular.module("HtJobPortal", ["LocalStorageModule", "ngSanitize"]);
var serviceBase = "http://htauth.htcsol.local:65200/";
var resourceBase = "http://localhost:50915/";
(function () {
   "use strict";

    app.constant("ngAuthSettings", {
        apiServiceBaseUri: serviceBase,
        apiResourceBaseUri: resourceBase,
        clientId: "TMS_Portal"
    });
    app.config(function ($httpProvider) {
        $httpProvider.interceptors.push("authInterceptorService");
    });
    app.run(["authService", function (authService) {
        authService.fillAuthData();
    }]);

})();

And then added the 'ng' attribute to the tags I want to see as HTML:

<div class="panel-body">
    <div class="col-lg-3 module text-center" ng-bind-html-unsafe="html">
        Jobs Module <br />
        {{settings.jobs}}
    </div>
    <div class="col-lg-3 module text-center" ng-bind-html-unsafe="html">
        Warehouse Module <br />
        {{settings.warehouse}}
    </div>
    <div class="col-lg-3 module text-center" ng-bind-html-unsafe="html">
        Stock Module <br />
        {{settings.stock}}
    </div>
    <div class="col-lg-3 module text-center" ng-bind-html-unsafe="html">
        Tracking Module <br />
        {{settings.tracking}}
    </div>
</div>

Is there something else I'm missing?

Upvotes: 0

Views: 31

Answers (1)

Mavlarn
Mavlarn

Reputation: 3883

which version of angularjs are you using? ng-bind-html-unsafe is removed from 1.2 version. If you want to bind html, you can use ng-bind-html. But you need to convert the html string with $sce.trustAsHtml(html) in you angular scope.

Upvotes: 1

Related Questions