I am trying to store a HTML inside a scope variable and then use it in template view. When I was reading how to do this in angular, I came across ng-bind-html
. In that I've noticed that when I bind html tags with <a>
, <strong>
, etc.. it works. But I am unable to add <input>
tags to it.
Meaning, this works:
$scope.myHtml = '<strong>This is <a hreaf="#">Something</a></strong>';
Template:
<p ng-bind-html="myHtml"> </p>
But this doesnt work:
$scope.myHtml = '<input type="text" />';
Template:
<p ng-bind-html="myHtml"> </p>
The above is just a simplified sample for demonstration purpose only. My question is:
1) Does tags not work with ng-bind-html directive?
2) If not, how can I html bind a input tag so I can insert it inside the view?
$http get
. – Lazecompile
function in that directive? – Xavierxaviera$sce.trustAsHtml()
function. I think it may work. Gonna give that a try and will update soon. :) – Lazeng-bind-html
or similar by declaring the compile function in the directive's directive definition object and mutating the template in there. – Xavierxavierang-bind-html
for this in the end. :) – Laze