ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
30 lines (24 loc) • 675 B
text/typescript
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import * as Prism from 'prismjs';
({
selector: 'nz-highlight',
template: `
<pre [ngClass]="'language-'+nzLanguage"><code [innerHTML]="nzCode"></code></pre>
`
})
export class NzHighlightComponent implements OnInit {
_code;
('code') codeElement: ElementRef;
() nzLanguage: string;
()
get nzCode(): string {
return this._code || '';
}
set nzCode(value: string) {
this._code = (Prism as any).highlight(value, (Prism.languages as any).javascript);
}
constructor() {
}
ngOnInit(): void {
}
}