テキストの中にリンクがあったら自動的にリンクになるやつ。
※同一URLがテキスト内に複数個あっても大丈夫なように修正
.filter('parseUrl', function($sce) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
return function(text, enable, target, style) {
if (!!+enable) {
target = target || '_blank';
style = style || null;
text = text.replace(exp,'<a target="' + target + '" style="' + style + '"href="$1">$1</a>');
return $sce.trustAsHtml(text);
}
return text;
};
});