Reputation: 552
Actual string - • Is Recovery Team assembled? • Critical timing for SLA's - are any impacted now, when will be if incident prolongs?
String getting displayed in textarea -
Please suggest..
HTML code:
<div class="form-group has-feedback">
<textarea class="form-control form-control-BCC" name="Notes" ng-model="buisnessSaveCommunication.BusinessContinutiydata.KeyMessage" spellcheck="true"></textarea>
</div>
here buisnessSaveCommunication in ng-model is alias.
angularjs :
scope.BusinessContinutiydata.KeyMessage = scope.keyMessge;
Upvotes: 1
Views: 3462
Reputation: 136194
The problem is you can't directly show encoded entities inside textarea
/input
box. What you could do is, before binding the value to textarea
decode it. For the same use $sanitize
service of ngSanitize
. Simply passing html
to $sanitize
service will return decoded html.
//Make sure you included `ngSanitize` module in your app module dependency
//Also add angular-sanitize.js with the same version that Angularjs has, otherwise it may conflict.
angular.module('app', ['ngSanitize'])
.controller('TestCtrl', function($scope, $sce, $sanitize) {
$scope.test = $sanitize('Critical timing for SLA's');
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular-sanitize.min.js"></script>
<body ng-app="app" ng-controller="TestCtrl">
<h1>{{test}}!</h1>
</body>
Otherwise you just need to do manually decoding before binding values to your textarea
. You can refer What's the right way to decode a string that has special HTML entities in it? for the same
In such cases I'd prefer you to use TextAngular
component, which provides similar thing with many additional feature.
Upvotes: 1