.filter('truncate', function () { return function (text, length, end) { if (isNaN(length)) length = 10; if (end === undefined) end = "..."; if (text.length <= length || text.length - end.length <= length) { return text; } else { return String(text).substring(0, length-end.length) + end; } }; })
przykład:
<span title="lorem ipsum lorem ipsum lorem ipsum">{{'bardzo dlugi tekst' | truncate:6}}</span>;
źródło:http://jsfiddle.net/tUyyx/
Reklamy