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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -