feat: docs app

This commit is contained in:
Sergey Andrievskiy 2019-07-16 08:38:11 +03:00
parent 62e6828680
commit 165e64eaca
203 changed files with 15928 additions and 6 deletions

View file

@ -0,0 +1,43 @@
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Input,
} from '@angular/core';
import { NgxCodeLoaderService } from '../../../@theme/services/code-loader.service';
@Component({
selector: 'ngx-example-block',
template: `
<ngx-code-block *ngIf="code"
[firstLine]="firstLine"
[lastLine]="lastLine"
[code]="code">
</ngx-code-block>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NgxExampleBlockComponent {
code: string;
firstLine: number;
lastLine: number;
@Input('content')
set setContent(content) {
this.loadCode(content);
}
constructor(private codeLoader: NgxCodeLoaderService, private cd: ChangeDetectorRef) {
}
loadCode(content) {
this.codeLoader.load(content.files[0])
.subscribe((code: string) => {
this.code = code;
this.firstLine = content.firstLine || 1;
this.lastLine = content.lastLine || code.split('\n').length;
this.cd.detectChanges();
});
}
}