答案 0 :(得分:1)
linky
过滤already supports www.abc.com类地址。
自己开发regexp以支持abc.xyz
是一项过于复杂而且吃力不讨好的工作。我建议使用成熟的第三方库,例如Autolinker。
Here is a simple module可能有助于配置(使用选项supported by Autolinker)并将其包装到角度过滤器中
angular.module('linkier', ['ngSanitize'])
.constant('linkierConfig', {})
.filter('linkier', ['$window', '$sanitize', 'linkierConfig',
function ($window, $sanitize, linkierConfig) {
return function (input, config) {
if (!angular.isString(input))
return input;
config = angular.extend({}, linkierConfig, angular.isObject(config) ? config : {});
return $sanitize($window.Autolinker.link(input, config));
};
}]);
答案 1 :(得分:0)
在文本输入中查找链接并将其转换为html链接。支持 http / https / ftp / mailto和普通电子邮件地址链接。
所以它似乎没有。您应该创建自己的过滤器来解决此问题。这是一个让你入门的模板。
<link href="/style-render?s=base" rel="stylesheet" type="text/css">
What is the best regular expression to check if a string is a valid URL?