I create a Pipe to do the translation until the angular-translate make it to ionic2.
I want this Pipe to be globally accessible from all other pages(components)
The @App is replaced with @Component and the solution described in first post is not applicable.
`
///
import {Component} from ‘@angular/core’;
import {provide, PLATFORM_DIRECTIVES} from ‘@angular/core’;
import {Platform, ionicBootstrap} from ‘ionic-angular’;
import {StatusBar} from ‘ionic-native’;
import {TabsPage} from ‘./pages/tabs/tabs’;
import {LangBundle} from ‘./ts/langBundle’;
import {eigonic} from ‘./ts/eigonic-translator’;
Sure thing, please notice that app wide service are put in the providers array as is, but app wide components needs to be provided to the PLATFORM_DIRECTIVES array before it can be passed to the providers array.
Thanks for the reply, Still not working for me. Here is app.ts
import {Component} from ‘@angular/core’;
import {provide, PLATFORM_DIRECTIVES} from ‘@angular/core’;
import {Platform, ionicBootstrap} from ‘ionic-angular’;
import {StatusBar} from ‘ionic-native’;
import {TabsPage} from ‘./pages/tabs/tabs’;
import {AppServices} from ‘./ts/appServices’;
import {AppCore} from ‘./ts/core’;
import {Common} from ‘./ts/common’;
import {LangBundle} from ‘./ts/langBundle’;
import {eigonic} from ‘./ts/eigonic-translator’;
First, app wide pipes also have to be used in the ionicBootstrap method.
Second, is eigonic a class? why using eigonic.Translator?, does that returns a directive, injectable or what?
I TOLD you, the component decorator doesn’t accept the providers array for app wide pipes, you have to put the app wide pipes & providers in the ionicBootstrap providers like:
import {Component} from '@angular/core';
import {provide, PLATFORM_DIRECTIVES} from '@angular/core';
import {Platform, ionicBootstrap} from 'ionic-angular';
import {StatusBar} from 'ionic-native';
import {TabsPage} from './pages/tabs/tabs';
import {AppServices} from './ts/appServices';
import {AppCore} from './ts/core';
import {Common} from './ts/common';
import {LangBundle} from './ts/langBundle';
import {eigonic} from './ts/eigonic-translator';
@Component({
template: ''
})
export class MyApp { ... }
ionicBootstrap(MyApp, [
AppServices.SharingService,
AppServices.StoringService,
provide(PLATFORM_DIRECTIVES, { useValue: [eigonic.Translator], multi: true })
])
And for gods sake search how markdown format code, the lack of colors in your code makes it harder to read.