-
Notifications
You must be signed in to change notification settings - Fork 1
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
.
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 { }
export class HttpTranslitRuleLoaderModule {
static withOptions(options: HttpTranslitRuleLoaderOptions)
: ModuleWithProviders<HttpTranslitRuleLoaderModule>
}
-
options
- An object of configuration options of typeHttpTranslitRuleLoaderOptions
.
/**
* 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;
}
-
HttpTranslitRuleLoader
- TheHttpTranslitRuleLoader
class that implements an HTTP client API for TranslitRuleLoader that relies on the AngularHttpClient
.