这是我目前的组成部分。
import { Component, OnInit, Input } from '@angular/core';
import { SaleInvoiceService } from "../../services/sale-invoice.service";
import { SaleInvoice } from "../../modules/sales/sale-invoice/sale-invoice";
@Component({
selector: 'fs-list',
templateUrl: 'fs-list.component.html',
styleUrls: ['fs-list.component.scss']
})
export class FSListComponent implements OnInit {
@Input() config: any;
data: SaleInvoice[];
constructor(private service: SaleInvoiceService) {}
ngOnInit() {
this.service.getAll()
.subscribe(data => {
this.result.data = data;
});
}
}
我需要根据fs-list组件输入值中提到的服务名称注入customerService,SupplierService,SaleInvoiceService等服务。有没有办法按需注入服务,而不是最初在构造函数