src/app/services/docs.service.ts
Properties |
Methods |
constructor(http: HttpClient)
|
||||||
Defined in src/app/services/docs.service.ts:18
|
||||||
Parameters :
|
getData | ||||||
getData(title: string)
|
||||||
Defined in src/app/services/docs.service.ts:21
|
||||||
Parameters :
Returns :
void
|
getID | ||||||
getID(title: string)
|
||||||
Defined in src/app/services/docs.service.ts:28
|
||||||
Parameters :
Returns :
any
|
getTitle | ||||||
getTitle(id: number)
|
||||||
Defined in src/app/services/docs.service.ts:32
|
||||||
Parameters :
Returns :
any
|
docsData |
Default value : new BehaviorSubject<string>('')
|
Defined in src/app/services/docs.service.ts:18
|
Behavior subject to return the markdown |
REGISTRY |
Default value : REGISTRY
|
Defined in src/app/services/docs.service.ts:13
|
List of all the docs pages |
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { REGISTRY } from '../static/docs';
@Injectable({
providedIn: 'root',
})
export class DocsService {
/**
* List of all the docs pages
*/
REGISTRY = REGISTRY;
/**
* Behavior subject to return the markdown
*/
docsData = new BehaviorSubject<string>('');
constructor(private readonly http: HttpClient) {}
getData(title: string) {
const index = REGISTRY.map((e) => e.urlTitle).indexOf(title);
this.http.get(REGISTRY[index].path, { responseType: 'text' }).subscribe((data) => {
this.docsData.next(data);
});
}
getID(title: string) {
return REGISTRY.map((e) => e.urlTitle).indexOf(title);
}
getTitle(id: number) {
return REGISTRY[id].urlTitle;
}
}