AngularJS : ngSanitize

by vishwackh89

HTML

<script src="//code.angularjs.org/1.2.1/angular-sanitize.min.js"></script>
<span id="output"></span>

<section ng-app="myApp">
    <article ng-controller="MyCtrl">
        <p ng-bind-html="html"></p>
    </article>
</section>

JavaScript

angular.module('controllers', []);
angular.module('myApp', ['controllers','ngSanitize']);
angular.module('controllers').controller('MyCtrl', function ($scope, $element, $compile, $timeout) {
    $scope.html = '<h1>More HTML content</h1><a href="http://google.com">This is a link</a>';
    console.log($scope);
    /*$timeout(function() {
        $compile($element[0].querySelector('p'))($scope);
    });*/
});