Mad_Griffith Posted March 14, 2016 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! Link to comment Share on other sites More sharing options...
justsomeguy Posted March 14, 2016 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now