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 &#35; b212'); 

working code example:

http://jsfiddle.net/egrendon/xa8cseoc/12/

right. need couple of things:

  1. inject ngsanitize module.
  2. 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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -