0

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?

1 Answer 1

1

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.

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.