Skip to content

Commit

Permalink
Merge pull request #23 from tflori/fix-angularbug
Browse files Browse the repository at this point in the history
use UseClass for providers
  • Loading branch information
tflori authored Apr 7, 2017
2 parents 2fbe973 + 797ad22 commit 042c6b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/TranslateComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TranslateService} from "./TranslateService";
import {TranslateService} from "./TranslateService";

import {Component, Inject, Input} from "@angular/core";

Expand Down
4 changes: 2 additions & 2 deletions src/TranslateLoaderJson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {TranslateLoader} from "./TranslateLoader";
import {TranslateLoader} from "./TranslateLoader";
import {Inject, Injectable} from "@angular/core";
import {Http} from "@angular/http";
import {Http} from "@angular/http";

export class TranslateLoaderJsonConfig {
public path: string = "assets/i18n/";
Expand Down
34 changes: 21 additions & 13 deletions src/TranslatorModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ import {TranslateService} from "./TranslateService
import {NgModule} from "@angular/core";
import {HttpModule} from "@angular/http";

export class DefaultTranslateConfig extends TranslateConfig {
constructor() {
super({});
}
}

export class DefaultTranslateLoaderJsonConfig extends TranslateLoaderJsonConfig {
constructor() {
super("assets/i18n/", ".json");
}
}

export const TRANSLATE_PROVIDERS: any[] = [
{ provide: TranslateConfig, useClass: DefaultTranslateConfig },
{ provide: TranslateLoaderJsonConfig, useClass: DefaultTranslateLoaderJsonConfig },
{ provide: TranslateLoader, useClass: TranslateLoaderJson },
TranslateLogHandler,
TranslateService,
];

@NgModule({
declarations: [
TranslatePipe,
Expand All @@ -20,19 +40,7 @@ import {HttpModule} from "@angular/http";
],
imports: [HttpModule],
providers: [
{ provide: TranslateConfig, useValue: new TranslateConfig({}) },
{ provide: TranslateLoaderJsonConfig, useValue: new TranslateLoaderJsonConfig() },
{ provide: TranslateLoader, useClass: TranslateLoaderJson },
{ provide: TranslateLogHandler, useClass: TranslateLogHandler },
TranslateService,
TRANSLATE_PROVIDERS,
],
})
export class TranslatorModule {}

export const TRANSLATE_PROVIDERS: any[] = [
{ provide: TranslateConfig, useValue: new TranslateConfig({}) },
{ provide: TranslateLoaderJsonConfig, useValue: new TranslateLoaderJsonConfig() },
{ provide: TranslateLoader, useClass: TranslateLoaderJson },
{ provide: TranslateLogHandler, useValue: TranslateLogHandler },
TranslateService,
];

0 comments on commit 042c6b3

Please sign in to comment.