-
-
Save fannheyward/6246547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.directive('markdown', function () { | |
var converter = new Showdown.converter(); | |
return { | |
restrict: 'AE', | |
link: function (scope, element, attrs) { | |
if (attrs.markdown) { | |
scope.$watch(attrs.markdown, function (newVal) { | |
var html = converter.makeHtml(newVal); | |
element.html(html); | |
}); | |
} else { | |
var html = converter.makeHtml(element.text()); | |
element.html(html); | |
} | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment