javascript - Covert encoded HTML in string to plain text for Input Fields using Agular -
i have use case, can have '&#' characters inside of json.
name: "kenneth hinsvark & maurice mcalister" address: "555555 w. canyon dr # b212"
the string values pulled database. apparently values saved db html encoding. need able display data in textfield without html characters.
my main requirement input fields values converted plain text.
name: <input type="text" ng-model="user.name" escape-to-plain-text></input> address: <input type="text" ng-model="user.address" escape-to-plain-text></input>
how can translated input values plain text?
using $sce isn't working me
$scope.user.name = $sce.trustashtml('555555 w. canyon dr # b212');
working code example:
right. need couple of things:
- inject
ngsanitize
module. - do
ng-bind-html
on element want output$sce
result.
i've edited fiddle here. - last line outputs correct # character
because outputs html, you'd need grab contents , parse them put them in input.. maybe in sense you'd better off doing match() on text values html entities.
Comments
Post a Comment