如何使用注入的服务来创建一个TypeScript类并实例化该类?假设您有一个Employee类,在其构造函数“ IEmployeeInfo”上具有一个参数以初始化对象,还具有注入的角度服务“ SomeService”。那么如何实例化该类呢?
export class Employee {
constructor(employeeInfo: IEmployeeInfo, _someService: SomeService) {}
//using the method from injected service
this._someService.doSomething(employeeInfo);
//methods
soSomeStuff(){...}
otherMethods(){..}
}
@Component({..})
export class employeeTransaction {
// how to instantiate a new Employee object?
const emp1 = new Employee(employeeArgs, service???);
emp1.doSomeStuff();
emp1.otherMethods();
}