typescript - Issue with globally visible service in Angular 2 -


i tying make service, visible without importing in component.

my bootstrap function:

export function main(initialhmrstate?: any): promise<any> {   console.log(app_providers);   return bootstrap(app, [     ...platform_providers,     ...env_providers,     ...app_providers   ])   .then(decoratecomponentref)   .catch(err => console.error(err)); } 

app providers definition:

export * './app.component'; export * './user.state'; export * './app.service';  import { userstate } './user.state'; import { appstate } './app.service';  // application wide providers export const app_providers = [   userstate,   appstate ]; 

and can not call in components constructor

 constructor( private userstate: userstate ) {}  

how can fix problem?

either importing or using string token or opaquetoken , `@inject()

export const app_providers = [   {provide: 'userstate', useclass: userstate},   appstate ]; 
constructor(@inject('userstate') private userstate: ) {}  

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -