I am having trouble putting a tag into my AngularJS web app. It loads data from a JSON file just fine. It also recognizes my HTML tags such as <em>
and <br />
. I achieved this through the $sce trustAsHtml. But it does not work for <input>
tags. I have tried for two days but I could not find a solution that works. Help and explanations are appreciated!
index.html
<div ng-bind-html="myName.name"></div> <!-- The Test from the data.json file shows up in italic but the input does not show up in the DOM -->
app.js
var myApp = angular.module('myApp', [
'ngRoute',
'ngSanitize',
'ngAnimate',
'QuizController'
]);
myApp.filter('trustAsHtml', [
'$sce',
function($sce) {
return function(value) {
return $sce.trustAsHtml(value);
}
}
]);
data.json
"name" : "<em>Test</em> <input type='text' name='Hello'>"