File

src/app/services/docs.service.ts

Index

Properties
Methods

Constructor

constructor(http: HttpClient)
Parameters :
Name Type Optional
http HttpClient No

Methods

getData
getData(title: string)
Parameters :
Name Type Optional
title string No
Returns : void
getID
getID(title: string)
Parameters :
Name Type Optional
title string No
Returns : any
getTitle
getTitle(id: number)
Parameters :
Name Type Optional
id number No
Returns : any

Properties

docsData
Default value : new BehaviorSubject<string>('')

Behavior subject to return the markdown

REGISTRY
Default value : REGISTRY

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;
  }
}

results matching ""

    No results matching ""