AngularJS: Ng-bind-html Doesn't Work With Button Tag
I am having problem to print out an input type button dynamically in a div 'ng-bind-html'. HTML template:
Solution 1:
For some reason your html tag is mark as unsafe
by angular js. If you sure that your snippet text is safe, you can $sce.trustAsHtml
it before adding it to the $scope.snippet
.
app.controller('yourCtrl', ['$scope', '$sce', function($scope, $sce){
$scope.add = function(){
var text = "<input type='button' value='Test'><b>Test 2</b>";
// mark it as clean
text = $sce.trustAsHtml(text);
$scope.snippet = text;
};
}]);
Post a Comment for "AngularJS: Ng-bind-html Doesn't Work With Button Tag"