`import {Component, ViewChild} from '@angular/core';
import {App, Platform, ionicBootstrap, MenuController, Nav} from 'ionic-angular';
import {provide} from '@angular/core';
import {Http, HTTP_PROVIDERS} from '@angular/http';
import {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';
import {StatusBar} from 'ionic-native';
import {TabsPage} from './pages/tabs/tabs';
import {RestaurantTipsPage} from './pages/restaurant-tips/restaurant-tips';
import {ShoppingTipsPage} from './pages/shopping-tips/shopping-tips';
import {TravellingPage} from './pages/travelling/travelling';
import {Trekking2Page} from './pages/trekking/trekking';
import {WeatherPage} from './pages/weather/weather';
import {ActactivitiesPage} from './pages/actactivities/actactivities';
/*
@Component({
template: '<ion-nav [root]="rootPage"></ion-nav>'
})*/
@Component({
templateUrl: 'build/app.html',
providers: [
{
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
},
TranslateService
]
})
export class MyApp {
rootPage:any = TabsPage;
pages: Array<{title:string, component:any, icon:string}>;
@ViewChild(Nav) nav: Nav;
static get parameters() {
return [[Platform], [MenuController]];
}
constructor(private platform:Platform, private menu: MenuController,private translate: TranslateService ) {
this.menu = menu;
this.pages = [
{title: 'Home', component: TabsPage, icon:'home'},
];
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
});
//this.translateConfig();
}
openPage(page) {
// close the menu when clicking a link from the menu
this.menu.close();
// navigate to the new page if it is not the current page
this.nav.setRoot(page.component);
}
translateConfig(){
var userLang = navigator.language.split('-')[0]; // use navigator lang if available
userLang = /(de|en|es)/gi.test(userLang) ? userLang : 'en';
// this language will be used as a fallback when a translation isn't found in the current language
this.translate.setDefaultLang('en');
// the lang to use, if the lang isn't available, it will use the current loader to get them
this.translate.use(userLang);
}
}
//ionicBootstrap(MyApp)
ionicBootstrap(MyApp, [[provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
}),
TranslateService]], {
});
`
The translate object in the constructor is undefined. Where to check it, why is this object not initialized? Thanx
Im using IONIC v2
And my app.ts is:
The translate object in the constructor is undefined. Where to check it, why is this object not initialized? Thanx