Hello,
I am trying to build an AngularJS 1.5 custom filter but there is some fault
in my logic: in the JS application part (see below) the ELSE IF block is
always true and the HTML is not sanitized:
portfolio.filter('BBCode', function($sce) {
return function(input, isRemoved) {
input = input || '';
var output;
if (angular.equals(isRemoved, 'remove')) {
output = input.replace(/\[(.*?)\]/g, '');
} else if(angular.isUndefined(isRemoved)) {
output = $sce.trustAsHtml(input.replace(/\[(.*?)\](.*?)\[(.*?)\]/g,
'<$1>$2<$3>'));
}
return output;
};
});
I would like the filter to behave like this in the view:
{{portfolio.title|BBCode}} // apply BBCode to expression value
{{portfolio.title|BBCode:'remove'}} // strip BBCode from expression value
I can have both expressions with the same value (e.g. 'portfolio.title') in
the same page.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.