ngsanitize

ng-bind-html doesnt work for Input tags

时光总嘲笑我的痴心妄想 提交于 2019-11-28 11:59:39
I am trying to store a HTML inside a scope variable and then use it in template view. When I was reading how to do this in angular, I came across ng-bind-html . In that I've noticed that when I bind html tags with <a> , <strong> , etc.. it works. But I am unable to add <input> tags to it. Meaning, this works: $scope.myHtml = '<strong>This is <a hreaf="#">Something</a></strong>'; Template: <p ng-bind-html="myHtml"> </p> But this doesnt work: $scope.myHtml = '<input type="text" />'; Template: <p ng-bind-html="myHtml"> </p> The above is just a simplified sample for demonstration purpose only. My

AngularJS using $sce.trustAsHtml with ng-repeat

穿精又带淫゛_ 提交于 2019-11-28 06:31:40
I'm trying to use $sce.trustAsHtml() with a property of an object in ng-repeat. The result is that the HTML is totally blank. The HTML outputs correctly using ngSanitize though. <div ng-repeat="question in questions"> <p ng-bind-html="$sce.trustAsHtml(question.body)"> </p> </div> I'm on AngularJS v1.3.0-beta.3 by the way. Not sure if there's a bug or I do something wrong. You can't use $sce.trustAsHtml in an expression (unless $sce is a property on the $scope ) because expressions are evaluated in the context of the $scope . The cleanest approach is to use ngSanitize . The second cleanest is

Angular sanitize / ng-bind-html not working?

蓝咒 提交于 2019-11-27 11:53:06
I've got a repeater set up and can get data to display as long as there is no html within it. I've included angular-sanitize.js and have tried using ng-bind-html But nothing is displayed within the span, only within the ng-bind-html attribute. So it looks like sanitise isn't working, I read that this needs to be added to the app dependencies but am not sure where to do so. I've just been working through the tut on the angular site so only have a very basic controller set up at the minute. Dan You need to include the angular-sanitize.js http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3

ng-bind-html doesnt work for Input tags

眉间皱痕 提交于 2019-11-27 06:39:53
问题 I am trying to store a HTML inside a scope variable and then use it in template view. When I was reading how to do this in angular, I came across ng-bind-html . In that I've noticed that when I bind html tags with <a> , <strong> , etc.. it works. But I am unable to add <input> tags to it. Meaning, this works: $scope.myHtml = '<strong>This is <a hreaf="#">Something</a></strong>'; Template: <p ng-bind-html="myHtml"> </p> But this doesnt work: $scope.myHtml = '<input type="text" />'; Template:

AngularJS using $sce.trustAsHtml with ng-repeat

十年热恋 提交于 2019-11-27 01:23:04
问题 I'm trying to use $sce.trustAsHtml() with a property of an object in ng-repeat. The result is that the HTML is totally blank. The HTML outputs correctly using ngSanitize though. <div ng-repeat="question in questions"> <p ng-bind-html="$sce.trustAsHtml(question.body)"> </p> </div> I'm on AngularJS v1.3.0-beta.3 by the way. Not sure if there's a bug or I do something wrong. 回答1: You can't use $sce.trustAsHtml in an expression (unless $sce is a property on the $scope ) because expressions are

Angular sanitize / ng-bind-html not working?

旧时模样 提交于 2019-11-26 15:47:19
问题 I've got a repeater set up and can get data to display as long as there is no html within it. I've included angular-sanitize.js and have tried using ng-bind-html But nothing is displayed within the span, only within the ng-bind-html attribute. So it looks like sanitise isn't working, I read that this needs to be added to the app dependencies but am not sure where to do so. I've just been working through the tut on the angular site so only have a very basic controller set up at the minute. 回答1