Angular2从方法参数对象中指定对象值



我正在开发Angular 5应用程序。我有模型类RoleClaimEntryDataModel,在一个可注入服务中,我有方法"UpdateRoleClaimById"接收RoleClaimEntryDataModel作为参数,我正试图将此对象分配给类的RoleClaimEntry DataModel,但我收到错误

错误

Type 'RoleClainEntryDataModel' is not assignable to type 'typeof RoleClaimEntryDataModel'/
Property 'prototype' is missing in type 'RoleClaimEntryDataModel'

型号类别

export class RoleClaimEntryDataModel{
roleId:string;
claimId:string;
isClaimAssignToRole:boolean;
}

可注入服务A

@Injectable()
export class UpdateRoleClaimCommand extends BaseCommand<boolean> {
public data = RoleClaimEntryDataModel;
initialise(): void {
super.setBody(this.data);
}
}

可注入服务B

@Injectable()
export class PermissionDataService{
constructor(
private updateRoleClaimCommand: UpdateRoleClaimCommand
){}
public UpdateRoleClaimById(roleClaimEntryDataModel: RoleClaimEntryDataModel)
{
this.updateRoleClaimCommand.data = roleClaimEntryDataModel; // throw error here
}

因为UpdateRoleClaimCommand中的data属性引用的是类型RoleClaimEntryDataModel,而不是类型RoleClaimEntryDataModel的变量

应该是这样的

@Injectable()
export class UpdateRoleClaimCommand extends BaseCommand<boolean> {
public data: RoleClaimEntryDataModel;
initialise(): void {
super.setBody(this.data);
}
}

最新更新