Angular Showdown directive compile

by maxisam

HTML

<script src="https://raw.github.com/coreyti/showdown/master/src/showdown.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<myhtml></myhtml>

JavaScript

angular.module('myApp', []).directive('myhtml', function($http) {
    var  data = $.param({
        json: JSON.stringify({
            html: '<div> from server</div>'
        }),
        delay: 1
    });

    return {
        restrict: 'E',
        scope: {},
        template: '',
        link: function(scope, element, attrs) {
            $http.post('/echo/json/', data).success(function(re) {
                element.html(re.html);
            });
        }
    }
});