I am looking to create a mardown directive (restrict A) which would make me able to use same recipient for ng-view. So I would basically load only .md files in views and apply my function on its content each time ng-view change. So :
index.html
<div markdown ng-view></div>
with two views containing, let say, view1.md
#That should be h1
and view2.md
##That should be h2, no ?
My actual code is
'use strict';
angular.module('btford.markdown', []).
directive('markdown', function () {
var converter = new Showdown.converter();
return {
restrict: 'A',
link: function (scope, element, attrs) {
scope.$watch(element.html(), function(value) {
var htmlText = converter.makeHtml(element.html());
element.html(htmlText);
});
var htmlText = converter.makeHtml(element.text());
element.html(htmlText);
}
}
});