Problem with $sce.trustAsHtml()

692 views
Skip to first unread message

mseth...@apptivo.co.in

unread,
Nov 4, 2014, 4:13:00 AM11/4/14
to ang...@googlegroups.com
I am using $sce.trustAsHtml for bind the HTML code . Before i tried ng-bind-html alone but that not supporting the style(i.e, font color, size ). so i using $sce.trustAsHtml  by two ways ,but even though it's not working

1st way

HTML code

<div class="email_quote" ng-bind-html="unsafe(emailData.message)">

JS code

$scope.unsafe = function(data)
{
return $sce.trustAsHtml(data);
}


Error on Console

  1. Error: [$sce:itype] http://errors.angularjs.org/1.2.23/$sce/itype?p0=html at Error (native) at http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:6:450 at trustAs (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:118:71) at Object.e.(anonymous function) [as trustAsHtml] (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:120:339) at k.$scope.updateView (http://localhost:8080/app/ajs/components/apptivo/emails/app/scripts/controllers/emailSidePanelViewController.js:585:43) at Object.fn (http://localhost:8080/app/ajs/components/apptivo/emails/app/scripts/controllers/emailSidePanelViewController.js:589:24) at k.$digest (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:109:403) at k.$apply (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:112:398) at h (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:72:454) at v (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:77:463) angular.1.2.23.min.js:92
  1. Uncaught object


2nd way

It's working fine,  but i have console error

Js code

$scope.emailData.message = $sce.trustAsHtml(emailData.message);


HTML code

<div class="email_quote" ng-bind-html="emailData.message">

Error

TypeError: undefined is not a function at z (http://localhost:8080/app/ajs/common/scripts/common/angular-sanitize.min.js:7:350) at http://localhost:8080/app/ajs/common/scripts/common/angular-sanitize.min.js:12:1 at Object.fn (http://localhost:8080/app/ajs/common/scripts/common/angular-sanitize.min.js:12:216) at k.$digest (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:109:403) at k.$apply (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:112:398) at h (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:72:454) at v (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:77:463) at XMLHttpRequest.w.onreadystatechange (http://localhost:8080/app/ajs/common/scripts/common/angular.1.2.23.min.js:79:24)


Please give the suggestion for above problem. any other way to handle this problem
Thank you  

Reply all
Reply to author
Forward
0 new messages