Reputation: 17422
I am getting error
Type 'number' is not assignable to type DeviceInput []
This is my code
id:number
reprobj:Reprocess;
this.reprobj.DeviceIds=this.id;
Model class code
export class DeviceInput
{
ID:number
}
export class Reprocess
{
Flag:boolean
ProductID:number
DeviceIds: DeviceInput[]
}
How can I solve this issue?
Upvotes: 1
Views: 69
Reputation: 851
This is an array:
DeviceIds: DeviceInput[]
This is a number:
id:number
You can't assign a number to an array. So make some changes:
export class DeviceInput
{
ID: number;
constructor(_id:number) {
this.ID = _id;
}
}
export class Reprocess
{
Flag: boolean;
ProductID: number;
DeviceIds: DeviceInput[] = [];
}
Your code:
this.reprobj.DeviceIds.push(new DeviceInput(someId));
Upvotes: 2