【发布时间】:2017-01-20 23:20:36
【问题描述】:
我已经为 Angular2 获取了最新的 RC0 剑道 UI。它的文档提到使用国际化服务。我已经创建了自定义 IntlService 并在我的应用程序模块中配置了它的提供程序。在组件中,如果我使用 IntlService 依赖项,则会调用我的自定义服务,但 NumericTextBox 没有调用我的服务。下面的代码有什么问题?
MyIntlService.ts
import { CldrIntlService } from '@progress/kendo-angular-intl';
import { Injectable } from '@angular/core';
@Injectable()
export class MyIntlService extends CldrIntlService {
constructor() {
super("en-US");
console.info('From MyIntlService ctor');
}
formatNumber(value: number, format: string| NumberFormatOptions){
const result = super.formatNumber(value,format);
console.log('In MyIntlService formatNumber');
return result;
}
}
app.module.ts
@NgModule({
imports: [ BrowserModule, InputsModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
providers: [{
provide: IntlService,
useClass: MyIntlService
}]
})
export class AppModule { }
app.component
export class AppComponent {
constructor(private intl: IntlService) {
console.log( " From AppComponent " + intl.formatNumber(42, "c"));
}
}
【问题讨论】:
标签: internationalization kendo-ui-angular2