本文整理匯總了TypeScript中ng2-translate/ng2-translate.TranslateModule類的典型用法代碼示例。如果您正苦於以下問題:TypeScript TranslateModule類的具體用法?TypeScript TranslateModule怎麽用?TypeScript TranslateModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TranslateModule類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StudentsComponent],
imports: [TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [Http]
})],
providers: [AngularService],
schemas: []
});
TestBed.compileComponents();
});
示例2: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, TranslateModule.forRoot({
provide: TranslateLoader,
useClass: AlfrescoTranslationLoader
})],
providers: [
AlfrescoTranslationService,
{provide: XHRBackend, useClass: MockBackend}
]
});
injector = getTestBed();
backend = injector.get(XHRBackend);
alfrescoTranslationService = injector.get(AlfrescoTranslationService);
backend.connections.subscribe((c: MockConnection) => connection = c);
alfrescoTranslationService.addTranslationFolder('fake-name', 'fake-path');
});
示例3: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
AlertComponent,
LoginComponent,
HomeComponent,
StudentsComponent,
// pipes
OrderByIdPipe,
OrderByNamePipe,
OrderBySurnamePipe
],
imports: [
NgbModule.forRoot(),
BrowserModule,
FormsModule,
HttpModule,
routing,
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [Http]
})
],
providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
AuthGuard,
AlertService,
AngularService,
AvatarService,
GradeService,
GroupService,
LoginService,
MatterService,
SchoolService,
UserService,
UtilsService
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
TestBed.compileComponents();
});
示例4: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [LoginComponent, HomeComponent, StudentsComponent],
imports: [
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [Http]
}),
FormsModule,
routing
],
providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
AlertService,
AngularService,
],
schemas: []
});
TestBed.compileComponents();
});
示例5: translateLoaderFactory
{
useHash: config.useHashRouting,
enableTracing: config.traceRoutes,
// errorHandler: error => console.log(`[ROUTER ERROR] : ${error}`),
preloadingStrategy: PreloadAllModules
})
];
export function translateLoaderFactory(http: Http) {
return new TranslateStaticLoader(http, 'assets/i18n', '.json');
}
const VENDOR_MODULES = [
TranslateModule.forRoot({
// provide: TranslateLoader,
// useClass: TranslationProvider
provide: TranslateLoader, deps: [Http],
useFactory: translateLoaderFactory
})
];
export {
ENV_PROVIDERS,
ENV_MODULES,
VENDOR_MODULES,
APP_PROVIDERS,
BIB_DIRECTIVES,
BIB_ACTIONS,
BIB_EFFECTS,
APP_DECLARATIONS
};
示例6:
const testModuleConfig = () => {
TestBed.configureTestingModule({
imports: [FormsModule, RouterModule, TranslateModule.forRoot()]
});
};