angular.module('form', []).controller('formcontroller', ['$scope', function($scope) { $scope.input; $scope.hello = "<h1> Welcome</h1>"; } ]); <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> </head> <body> <form ng-app="form" ng-controller="formcontroller"> <span ng-bind="hello"></span> <span ng-bind-html="hello"></span> </form> </body> </html> I tried by using
It results in the output as
<h1> Welcome</h1> I tried by replacing ng-bind-html is not woking and throws an error.
<script> angular.module('form', []).controller('formcontroller', ['$scope', function($scope) { $scope.hello="<h1> Welcome</h1>"; }]); </script>Error: $sce:unsafe Require a safe/trusted value Attempting to use an unsafe value in a safe context.
Please explain.