I use Angular and have 1 component, 1 class and 1 service.
My service is an @injectable class and well setted in app.module.ts.
@Injectable()
export class MyService {
My class get the service as an dependency injection.
import { MyService } from '../services/myService';
export class MyClass {
constructor(
myService: MyService
) {
In the component constructor i try to make a new instance of my class MyClass.
export class MyComponent implements AfterViewInit {
constructor(
) {
const myClass = new MyClass();
}
But i got : "Expected 1 arguments, but got 0".
So my question is how use classes and enjoy Dependency Injection ? I found nothing clear about that.
Or, i have to add the depencies in my component constructor and pass them to my class ?
A better way to mix maybe ?
Thanks in advance,