0

I am busy making an app in Ionic and I am running into a problem with a JSON string that contains HTML.. The JSON is getting pulled off a Joomla site and seems to be retaining the HTML tags and special chars.. The string looks like this: "<div>Apple aims to have its smart watch on wrists in China

I looked around and found that I should use ng-bind-html but that only outputs the actual tags as strings like this: <div>Apple aims to have its smart watch on wrists in China

Is there any way to either get rid of the HTML altogether or to escape it maybe?

1 Answer 1

1

You could pass the HTML text through .replace to get rid of the tags

var yourstring = "&lt;div&gt;Your text content&lt;/div&gt;";
yourstring = yourstring.replace(/&lt;[^&]*&gt;/g, '');
// yourstring is now "Your text content"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.