Friday, 15 March 2013

javascript - Angularjs - Convert into plain text -



javascript - Angularjs - Convert <br/> into plain text -

my text doesn't convert plain text contain <br/> html tag.

i want this

hi i'm nurdin !!

not

hi <br/> <br/> i'm nurdin!!

html

<textarea name="" cols="" rows="" class="form-control" ng-model="rule.message" ></textarea>

js

xxxxxcontrollers.controller('memberruleupdatectrl', ['$scope', '$routeparams', '$location', '$http', function($scope, $routeparams, $location, $http) { $scope.rule = {}; $http({ method: 'get', url: 'http://xxxxx.my/api/get_rule_details.php?ruleid=' + $routeparams.ruleid }). success(function(data, status, headers, config) { $scope.rule = { message: data.rule[0].message }; }). error(function(data, status, headers, config) { alert("no net connection."); }); } ]);

please advice. give thanks you.

providing html formatting beingness saved db/datasource displaying follows

<div ng-bind-html="rule.message" > obey formatting.

you need include angular sanitize module project.

edit

after reading question 1 time again think misunderstood bit here more detailed answer.

if you'd see how display html encoded string in div take @ plunk http://plnkr.co/edit/cpsfl8y0wwptvxwo4oyr?p=preview

if display html encoded string in textarea while keeping formatting - not possible - textarea doesn't deal html far know.

if still want display html encoded string in 'textarea` formatting need utilize http://textangular.com/ - replaces textarea div looks , behaves textarea hence why it's able display proper html formatting

javascript angularjs

No comments:

Post a Comment