[Django]-AngularJs data binding in ajax html response

4👍

Create directive to $compile your html.

angular.module("app").directive('compilehtml', ["$compile", "$parse", function($compile, $parse) {
    return {
        restrict: 'A',
        link: function($scope, element, attr) {
            var parse = $parse(attr.ngBindHtml);
            function value() { return (parse($scope) || '').toString(); }

            $scope.$watch(value, function() {
                $compile(element, null, -9999)($scope); 
            });
        }
    }
}]);   

Then add this directive

<div ng-bind-html="form" compilehtml></div>

DEMO

Leave a comment