orchardcms - Error: [$sce:unsafe] AngularJS 1.2.20 -


i'm creating web site using orchard cms , angularjs 1.2.20 , i'm trying render html code i'm getting error

 error: [$sce:unsafe] http://errors.angularjs.org/1.2.20/$sce/unsafe     v/<@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:6:450     be/this.$get</e@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:117:34     be/this.$get</<.gettrusted@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:118:327     @http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:120:71     kd</</<@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:191:341     zd/this.$get</k.prototype.$digest@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:109:170     zd/this.$get</k.prototype.$apply@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:112:171     h@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:72:452     w@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:77:347     we/</z.onreadystatechange@http://www.angularjshub.com/code/angularjs/repository/angular-1.2.20/angular.min.js:78:420 

this script:

   var firstcontroller = function ($scope, $http, $interval, $sce) {  $http.get(apiurl + "/authors)     .success(function (data, status, header, config) {         $scope.names = data;     });       $scope.renderhtml = function (html_code) {             return $sce.trustashtml(html_code);         }; 

this view:

<div ng-bind-html="renderhtml(authors.photo)"></div> 

this happens because have not marked html safe using $sce.trustashtml see have done perfectly. can create simple fiddle reproduce same.

html code:

<h2>rendering html angularjs</h2> <div ng-app="angularapp" ng-controller="appcontroller">     <div ng-bind-html="renderhtml(content)"></div>    </div> 

js code:

var app = angular.module("angularapp", []); app.controller("appcontroller", function($scope, $sce){     $scope.content = "this text <em>html capable</em> meaning can have <a href=\"#\">all</a> sorts <b>of</b> html in here.";     $scope.renderhtml = function(html){         return $sce.trustashtml(html);     }; }); 

http://jsfiddle.net/x2vxxbya/1/


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -