В настоящее время я работаю с ng-bind-html. По сути, то, что я пытаюсь сделать, это когда я публикую блог, блог содержит ссылки и другие стили. Поэтому, когда я пытаюсь показать список блогов, я использую ng-bing-html следующим образом:
<p ng-bind-html="blog.blogContent"></p>
который отлично работает.
Но, кроме того, я пытаюсь обрезать блог и показывать только несколько абзацев с опцией «Просмотреть больше», передавая пользовательский фильтр. Но когда я прохожу фильтр, я получаю следующее:
<p ng-bind-html="blog.blogContent | Truncate"></p>
Error: [$sanitize:badparse] The sanitizer was unable to parse the
following block of html: <a href="https:.......
Мой фильтр выглядит так:
return function (text, length, end) {
if (text !== undefined) {
if (isNaN(length)) {
length = 450;
}
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;
}
}