Reputation: 46909
I was not very clear in my last question. However after seeing the response from the server asking the same again. The html is not getting rendered here how to fix this
AppControllers.controller('create', ['$scope','$sce', function ($scope,$sce){
var myhtml = "<div class="modal-body " id="mymodal">
<form name="form" novalidate="" class="add-user">
<fieldset>";
$scope.myhtml= $sce.trustAsHtml(myhtml)
console.log($scope.myhtml)
/* Output of console.log
<div class="modal-body " id="mymodal">
<form name="ticketform" novalidate="" class="add-user-from ">
*/
}
<div ng-bind-html="myhtml"></div>
Upvotes: 0
Views: 4818
Reputation: 21901
try something like this,
Decode the html string and pass it to ng-bind-html
.
add jquery also.
var myhtml = "<div class="modal-body " id="mymodal">
<form name="" novalidate="" class="add-user ">
<fieldset>";
$scope.decodedText = $('<textarea />').html(myhtml).text();
<div ng-bind-html="decodedText"></div>
OR IF you prefer No Jquery use this,
var myhtml = "<div class="modal-body " id="mymodal"><form name="ticketform" novalidate="" class="add-user-from add_ticket"><fieldset>";
var txt = document.createElement("textarea");
txt.innerHTML = myhtml;
$scope.decodedText = txt.value;
<div ng-bind-html="decodedText"></div>
Upvotes: 4