Open caiizilaz opened 7 years ago
Hi
I know I am a little late, but I had a similar problem and it took me quite some time to solve, so I decided to share if anyone experiences the same problem in the future.
The solution turned out quit simple for me.
First, I installed prismjs using:
npm install prismjs
Then I used the following Typescript syntax that is equivalent to "require"
import * as Prism from "prismjs";
Then I simply called:
Prism.highlightAll();
Please note that you need to call this function inside AfterViewInit, instead of OnInit.
Moreover, I was getting my text from a rxjs subscription and calling Prism.highlightAll();
simply didn't work, so I had to replace it with: setTimeout(Prism.highlightAll, 10);
so that it is executed only after the DOM has been updated.
Note: it works with 1 millisecond but I am using 10 just to be safe.
And It worked like a charm!
when i innerHTML on the div with trusthtml pipe and i see in the chrome inspect, it look like span element with token class was disappear.