Reputation: 1655
I want to parse the following strings in an Input:
<>, <, >, = (without comma)
The Input will be binded by this Snippet:
JS
$scope.json = null;
$scope.filter = JSON.parse(data);
$scope.$watch('filter', function (newValue) {
$scope.json = JSON.stringify(newValue, null, 2);
$scope.output = computed(newValue.group);
}, true);
If I now use:
<input type="text" ng-bind="output"/>
I get the output: <>
(for eg for <>)
If I use
<input type="text" ng-bind-html="output"/>
Nothing happens.
Correct would be the <> in the input
Is there an easy way to do this?
Upvotes: 0
Views: 265
Reputation: 19708
Use the ngModel
binding to automatically parse these characters.
<input ng-model="text">
Upvotes: 0
Reputation: 873
Use this filter to parse your operators.
filter("decode",function(){
return function(str){
var el = document.createElement("div");
el.innerHTML = str;
str = el.innerText || el.textContent;
return str;
}
})
Html
<input type="text" ng-bind="model|decode" />
Upvotes: 1