Your Helper class corresponds to a service and since you want to inject another service in you need add the @Injectable
decorator (not the @Component
one):
Import {Injectable} from 'angular2/core';
@Injectable()
export class Helper {
(...)
}
Since it's part of dependency injection, all parameters of its constructor will be provided by Angular2 itself. You don't need to provide them by your own and instantiate yourself this class to be able it. Simply inject it where you want to use it...
You need then to the corresponding provider at when bootstrapping your application:
bootstrap(AppComponent, [ Helper ]);
Or at a component level but can only be used within processing triggered by the component.
@Component({
(...)
providers: [ Helper ]
})
export class SomeComponent {
(...)
}
For more details about dependency injection and hierarchical injectors, you could have a look at this question:
- No provider for ObservableDataService