Add HTML tags inside string

Hi all ! Could anyone suggest please, is it possible in Ionic2 add such kind string to for example ?

"SERVI<span class='search_result'>c</span>E BULLETINS"

Assuming I understood you correctly, here’s how:

let stringwithhtml = "SERVI<span class='search_result'>c</span>E BULLETINS";
<div [innerHTML]="stringwithhtml"></div>
1 Like

mich356c, thanks, it working.

mich356c, Is it possible where I do not need, cut all html from string ?

Check out this: How to remove HTML tags from content?

Edit: It’s really only this part which is relevant

strip(html: string) {
	return html.replace(/<(?:.|\n)*?>/gm, '');

You can add that to a pipe if you want, so it’s just {{stringwithhtml | stripHTML}}

import { Injectable, Pipe } from '@angular/core';

	name: 'stripHTML'
export class stripHTML {
	transform(html: string) {
		return html.replace(/<(?:.|\n)*?>/gm, '');

I think regular expressions are not sufficiently capable of parsing HTML. If you’re really serious about this, I would look into incorporating a real HTML parser.

mich356c, It help, thanks.

How to add inside string? It appears but the can’t be checked or unchecked.