ng-bind-html

Why is ng-bind-html not displaying anything?

做~自己de王妃 提交于 2019-12-04 11:17:50
问题 I am displaying a string that has HTML code in it: <div style="font-size: 14px" ng-bind="currentBook.description"></div> put it displays the HTML code instead of interpreting the elements: When I use ng-bind and ng-bind-unsafe , it shows nothing. How can I get the HTML to be parsed? Addendum I added a reference to sanitize but ng-bind and ng-bind-unsafe still show nothing: <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> <script src="http://ajax

Why is ng-bind-html not displaying anything?

大兔子大兔子 提交于 2019-12-03 06:23:05
I am displaying a string that has HTML code in it: <div style="font-size: 14px" ng-bind="currentBook.description"></div> put it displays the HTML code instead of interpreting the elements: When I use ng-bind and ng-bind-unsafe , it shows nothing. How can I get the HTML to be parsed? Addendum I added a reference to sanitize but ng-bind and ng-bind-unsafe still show nothing: <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-route.js"></script> <script src="http://ajax.googleapis

AngularJS 1.2.0 ngBindHtml and trustAsHtml not working with ngModel

不羁岁月 提交于 2019-12-02 02:10:37
问题 I feel like this should be really easy since I had it working perfectly with Angular 1.0.8 using ngBindHtmlUnsafe. I read on the API docs and on StackOverflow that I need to use $sce.trustAsHtml() with ngBindHtml now but I cannot seem to get it to work. This is basically the format I am using given what I read: var myApp = angular.module('myApp', []); function myController($scope, $sce){ $scope.myHtml = $sce.trustAsHtml($scope.sourceText); } html: <html ng-app="myApp"> <head> <script data

ng-click won't work with ng-bind-html

旧街凉风 提交于 2019-12-02 01:03:19
问题 I have html template like this: $scope.template = '<span class="pointer"><i class="icon-refresh pointer" ng-click="refresh()"></i></span>'; I want to bind this template using ng-bind-html , I tried to use it and also I used ng-bind-html-unsafe , but unfortunately It bind the html string as it is with no click action. <span ng-bind-html="template"></span> <span ng-bind-html-unsafe="template"></span> I read about similar problem and it said that ng-click is loaded after ng-bind , so can anybody

AngularJS 1.2.0 ngBindHtml and trustAsHtml not working with ngModel

北城以北 提交于 2019-12-01 22:49:32
I feel like this should be really easy since I had it working perfectly with Angular 1.0.8 using ngBindHtmlUnsafe. I read on the API docs and on StackOverflow that I need to use $sce.trustAsHtml() with ngBindHtml now but I cannot seem to get it to work. This is basically the format I am using given what I read: var myApp = angular.module('myApp', []); function myController($scope, $sce){ $scope.myHtml = $sce.trustAsHtml($scope.sourceText); } html: <html ng-app="myApp"> <head> <script data-require="angular.js@1.2.0-rc3" data-semver="1.2.0-rc3-nonmin" src="http://code.angularjs.org/1.2.0-rc.3

Using ng-bind-html and $sce.trustAsHtml create a string with ng-model binding

最后都变了- 提交于 2019-11-29 15:33:16
I want to create dynamically forms. Inside my controller i create a string var str = "<input type='text' value='" + $scope.selectedData.code + "' class='form-control' />"; $scope.htmlString = $sce.trustAsHtml(str); and in my html page <div ng-bind-html="htmlString"></div> i get the value but is not binding. I try also with var str = "<input type='text' ng-model='" + $scope.selectedData.code + "' class='form-control' />"; $scope.htmlString = $sce.trustAsHtml(str); also doesn't work. Can anyone know how can this work? HTML : Add a directive: compile-template <div ng-bind-html="htmlString"

Angular JS shows HTML within the tag

自闭症网瘾萝莉.ら 提交于 2019-11-28 16:22:55
I am trying to insert HTML inside template using ng-bind-html-unsafe attribute. But for some reason its not working. My code: <tr class="white two-button" ng-repeat="(key,value) in recommendations | ojoScoreFilter:ojoScore | relevancyScoreFilter:relevancyScore | orderBy:predicate:reverse"> <td> <div ng-bind-html-unsafe="value.button"></div> </td> </tr> I am not able to see the HTML. If I change ng-bind-html-unsafe="value.button" to ng-bind-html-unsafe="{{value.button}}" then it shows HTML but within the attribute, something like this: <div ng-bind-html-unsafe="<a class="action_hrefs full-width

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

How to watch for ng-model created with ng-bind-html

不羁的心 提交于 2019-11-28 11:15:28
I need some help with an ng-model created with ng-bind-html. I have a JSON file in the server in which I have some html and some inputs like this: *.json { "test": { "1": { "question":"<span>1. something:</span>", "options":"<input type='radio' name='q1' ng-model='q.1' value='a'>a) op 1<br><input type='radio' name='q1' ng-model='q.1' value='b'>b) op 2<br><input type='radio' name='q1' ng-model='q.1' value='c'>c) op 3<br><input type='radio' name='q1' ng-model='q.1' value='d'>d) op 4<br><input type='radio' name='q1' ng-model='q.1' value='e'>e) op 5<br>", "answer":"c" }, "2": { ... } } } Then in

Using ng-bind-html and $sce.trustAsHtml create a string with ng-model binding

独自空忆成欢 提交于 2019-11-28 10:02:22
问题 I want to create dynamically forms. Inside my controller i create a string var str = "<input type='text' value='" + $scope.selectedData.code + "' class='form-control' />"; $scope.htmlString = $sce.trustAsHtml(str); and in my html page <div ng-bind-html="htmlString"></div> i get the value but is not binding. I try also with var str = "<input type='text' ng-model='" + $scope.selectedData.code + "' class='form-control' />"; $scope.htmlString = $sce.trustAsHtml(str); also doesn't work. Can anyone