|
1 |
| -import { Component, ElementRef, ViewChild, OnInit } from '@angular/core'; |
| 1 | +import { |
| 2 | + Component, |
| 3 | + ElementRef, |
| 4 | + ViewChild, |
| 5 | + OnInit, |
| 6 | + ViewEncapsulation, |
| 7 | + ApplicationRef |
| 8 | +} from '@angular/core'; |
2 | 9 | import { Location } from '@angular/common';
|
3 | 10 | import { ApiService } from './api.service';
|
4 |
| -import { tap } from 'rxjs/operators'; |
| 11 | +import { BasePageComponent } from '../pages/page/page.component'; |
5 | 12 |
|
6 | 13 | @Component({
|
7 | 14 | templateUrl: './api.component.html',
|
8 |
| - styleUrls: ['./api.component.scss'] |
| 15 | + styleUrls: ['./api.component.scss'], |
| 16 | + encapsulation: ViewEncapsulation.None |
9 | 17 | })
|
10 |
| -export class ApiComponent implements OnInit { |
| 18 | +export class ApiComponent extends BasePageComponent implements OnInit { |
11 | 19 | @ViewChild('content') contentRef: ElementRef<HTMLDivElement>;
|
12 | 20 | isDetailPage = false;
|
13 | 21 |
|
14 |
| - constructor(private location: Location, private api: ApiService) {} |
| 22 | + constructor( |
| 23 | + private location: Location, |
| 24 | + private api: ApiService, |
| 25 | + applicationRef: ApplicationRef, |
| 26 | + el: ElementRef |
| 27 | + ) { |
| 28 | + super(applicationRef, el); |
| 29 | + } |
15 | 30 |
|
16 | 31 | private loadContent(path) {
|
17 | 32 | if (path === '/api' || path === '/api/') {
|
18 | 33 | this.isDetailPage = false;
|
19 | 34 | } else {
|
20 | 35 | this.isDetailPage = true;
|
21 |
| - this.api |
22 |
| - .getDocument(path) |
23 |
| - .subscribe( |
24 |
| - content => (this.contentRef.nativeElement.innerHTML = content) |
25 |
| - ); |
| 36 | + this.api.getDocument(path).subscribe(content => { |
| 37 | + this.contentRef.nativeElement.innerHTML = content; |
| 38 | + super.initHljs(); |
| 39 | + }); |
26 | 40 | }
|
27 | 41 | }
|
28 | 42 | ngOnInit() {
|
|
0 commit comments