angularjs ng-bind-html html input part missing -
i have included ngsanitize display html in bind-html have bind following in code:
$scope.discslist = '<div class="items text-center"><img src="assets/uploads/discs/'+obj.image+'" class="img-circle"><br><input type="radio" id="chkdisc'+obj.id+'" name="chkdisc" value="'+obj.id+'" required data-ng-model="formdata.disc"></div>';
and in controller have included $sanitize
it binds html ng-bind-html="disclist" div images , div added, input element missing that:
<div class="items text-center"><img src="assets/uploads/discs/disc9.png" class="img-circle"><br></div>
i wants bind html div.
i using angularjs 1.4
here have tried.
js
angular.module("test",['ngsanitize']) .controller("testctrl",['$scope','$sce',function($scope,$sce){ $scope.discslist = '<div class="items text-center">'+ '<img src="assets/uploads/discs/test.png" class="img-circle"><br>'+ '<input type="radio" id="chkdiscid" name="chkdisc" value="1" required data-ng-model="formdata.disc">'+ '</div>'; $scope.discslist = $sce.trustashtml($scope.discslist);;
}])
html
<body ng-controller="testctrl"> <div ng-bind-html="discslist"></div> <script type="text/javascript" src="angular.js"></script> <script type="text/javascript" src="angular-sanitize.js"></script> </body>
make sure have include angular-sanitize.js , injected ngsanitize module in app , injected $sce in controller.
Comments
Post a Comment