I have a decorated model class:
@Api('payments/deposit')
export class DepositsModel {
public id: number;
public created_at: Date;
...
In angular component constructor I'm injecting data service pointing to use my model class:
...
public constructor(
private $api: GridApiService<DepositsModel>
...
) {
this.service = new GridService($api);
...
}
...
So, my cool component has a cool service, witch knows the type of data it work with...
Should know..
But how I can to get my model's metadata in my GridApiService? I've tried:
@Injectable()
export class GridApiService<T>{
constructor(
$http: HttpClient,
) {
let api = Reflect.getMetadata('Api', T);
}
And got Error message: 'T' only refers to a type, but is being used as a value here.
UPDATE
Can you advice me another way to pass initialization data to my GridApiService, witch should be injected through DI, not created with new keyword?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…