Displaying Colored Logs with Search Highlighting in Angular 6
1. Project Setup
npm install prismjsimport * as Prism from 'prismjs';
import 'prismjs/components/prism-log'; // Prism's Log language
import 'prismjs/prism';2. Component HTML Template
<div *ngIf="logsByLine && logsByLine.length > 0" style="height: 80vh;">
<pre class="language-log w-100 scroll" style="height: 100%; overflow-y: auto;">
<code [ngClass]="{'white-space-pre-wrap': isTextWrapped}"
class="language-log"
[innerHTML]="getHighlightedContent()"></code>
</pre>
</div>3. Component TypeScript Logic
4. View Encapsulation and Sanitization
5. Component Styles (SCSS)
6. Conclusion
PreviousHow to Open a PDF or an Image in Angular Without DependenciesNextImplementing Auto-Suggestion in Input Field in Angular Template-Driven Forms
Last updated