У меня проблема со знанием внедрения зависимостей в Angular 6.
Сцена выглядит следующим образом:
Один класс (используется в качестве модели):
import { NgModule } from '@angular/core';
import { ContactProviderService } from './../services/contact-provider.service';
import { SuiviInterface } from './../interfaces/suiviinterface';
import { WebapiService } from './../services/webapi.service';
import { QuotationInterface } from './../interfaces/quotationinterface';
import { DeserializableInterface } from './../interfaces/deserializableinterface';
import { MomentDate } from './momentdate';
import { User } from './user';
import { Feature } from './feature';
import { Suivi } from './suivi';
@NgModule({
providers: [
WebapiService,
ContactProviderService
]
})
export class Quotation implements QuotationInterface, DeserializableInterface<Quotation> {
public id: number;
public date: MomentDate;
public user: User;
public feature: Feature;
public dateValidation?: MomentDate;
public dateProposition?: MomentDate;
public dateAcceptation?: MomentDate;
public isArchive: Boolean;
public isDeleted: Boolean;
public numParcelle: string;
public commentaire: string;
public lead?: string;
public suivi: Array<Suivi>;
public propositionDone: boolean = false;
private nbAttributions: number = 0;
private nbPropositions: number = 0;
public constructor(
private webApi: WebapiService,
private contactProvider: ContactProviderService) {
this.dateValidation = null;
}
... some getters / setters
public deserialize(input: any): Quotation {
Object.assign(this, input);
// some other stuff
return this;
}
}
}
В этом классе и WebapiService, и ContactProviderService являются инъецируемыми, поэтому я подумал, что самодостаточно ввести их в контуре класса.
Я добавил @NgModule, чтобы попробовать ... но когда ясоздать экземпляр цитаты, иметь следующую ошибку:
Expected 2 arguments but got 0
Что я делаю не так?
Thx,
Жан-Люк