Tuesday, October 3, 2017

HTML string not binded with angular [duplicate]

This question already has an answer here:

<!DOCTYPE html
<body>

<div ng-app="myApp" ng-controller="myCtrl">

<p ng-bind-html="myText"></p>

</div>

<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
    $scope.myText = "<input type='text' value='here'>";
});
</script>

<p><b>Note:</b> This example includes the "angular-sanitize.js",
which has functions for removing potentially dangerous tokens from the HTML.</p>

</body>
</html>

I’m new to angular as well. I could not bind the html text to the angular view. Any suggestions could help.

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/03/html-string-not-binded-with-angular-duplicate/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment