Skip to content

HttpTranslitRuleLoaderModule

Moe Myat Zaw edited this page Jun 7, 2019 · 1 revision

Implements an HTTP client API for TranslitRuleLoader that relies on the Angular HttpClient.

Getting Started

Module Setup (app.module.ts)

import { TranslitModule } from '@dagonmetric/ng-translit';
import { HttpTranslitRuleLoaderModule } from '@dagonmetric/ng-translit/http-loader';

export function translitEndpointFactory(baseUrl: string, ruleName: string): string {
  return `${baseUrl}rules/${ruleName}.json`;
}

@NgModule({
  imports: [
    // Other module imports

    // ng-translit
    TranslitModule,
    HttpTranslitRuleLoaderModule.withOptions({
      baseUrl: 'https://zawgyi-unicode-translit-rules.myanmartools.org/',
      endpointFactory: translitEndpointFactory
    })
  ]
})
export class AppModule { }

HttpTranslitRuleLoaderModule API

export class HttpTranslitRuleLoaderModule {
  static withOptions(options: HttpTranslitRuleLoaderOptions)
    : ModuleWithProviders<HttpTranslitRuleLoaderModule>
}

Parameters

  • options - An object of configuration options of type HttpTranslitRuleLoaderOptions.

HttpTranslitRuleLoaderOptions

/**
 * The HttpTranslitRuleLoaderOptions interface.
 */
export interface HttpTranslitRuleLoaderOptions {
  /**
   * The base url string or InjectionToken.
   */
  baseUrl?: string | InjectionToken<string>;
  /**
   * The endpoint factory method.
   */
  endpointFactory?(baseUrl: string, ruleName: string): string;
}

Providers

  • HttpTranslitRuleLoader - The HttpTranslitRuleLoader class that implements an HTTP client API for TranslitRuleLoader that relies on the Angular HttpClient.