Mad_Griffith 0 Posted March 14, 2016 Report Share Posted March 14, 2016 Hello, I am learning Angular and I am trying to create a more complex filter that replaces BBCode with the html tags, which works like this: {{app.text|BBCode}} With no parameter, show the text with the BBCode converted to HTML tags. {{app.otherText|BBCode:remove}} If parameter "remove" is specified, then actually strip BBCode from text. I use both at the same time in my html. This is the simple code, but it doesn't work: the first IF is skipped. When I log 'isRemoved' it shows up as 'undefined' for all the occurrences of the expressions, including those with the 'remove' parameter specified. portfolio.filter('BBCode', function() { return function(input, isRemoved) { input = input || ''; var output; if (angular.isDefined(isRemoved) && angular.equals(isRemoved, 'remove')) { output = input.replace(/\[(.*?)\]/g, ''); } else { output = input.replace(/\[(.*?)\]/g, '<$1>'); } return output; }; }); Thank you for your help! Quote Link to post Share on other sites
justsomeguy 1,135 Posted March 14, 2016 Report Share Posted March 14, 2016 What does the code look like that uses that function? In other words, how does it get called where the second parameter is undefined? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.