Angular2从方法参数对象指定对象值
我正在处理Angular 5应用程序。我有模型类RoleClaimEntryDataModel,在一个可注入服务中,我有方法'UpdateRoleClaimById'接收RoleClaimEntryDataModel作为参数,我试图将此对象分配给类的RoleClaimEntryDataModel,但我得到错误 错误 模范班 可注入服务AAngular2从方法参数对象指定对象值,angular,typescript,Angular,Typescript,我正在处理Angular 5应用程序。我有模型类RoleClaimEntryDataModel,在一个可注入服务中,我有方法'UpdateRoleClaimById'接收RoleClaimEntryDataModel作为参数,我试图将此对象分配给类的RoleClaimEntryDataModel,但我得到错误 错误 模范班 可注入服务A 因为UpdateRoleClaimCommand中的data属性引用的是类型RoleClaimEntryDataModel,而不是类型RoleClaimEntr
因为
UpdateRoleClaimCommand
中的data
属性引用的是类型RoleClaimEntryDataModel
,而不是类型RoleClaimEntryDataModel
应该是这样的
@Injectable()
export class UpdateRoleClaimCommand extends BaseCommand<boolean> {
public data: RoleClaimEntryDataModel;
initialise(): void {
super.setBody(this.data);
}
}
@Injectable()
导出类UpdateRoleClaimCommand扩展BaseCommand命令{
公共数据:RoleClaimEntryDataModel;
初始化():void{
super.setBody(这个数据);
}
}
因为UpdateRoleClaimCommand
中的数据
属性引用的是RoleClaimEntryDataModel类型
,而不是RoleClaimEntryDataModel类型的变量
应该是这样的
@Injectable()
export class UpdateRoleClaimCommand extends BaseCommand<boolean> {
public data: RoleClaimEntryDataModel;
initialise(): void {
super.setBody(this.data);
}
}
@Injectable()
导出类UpdateRoleClaimCommand扩展BaseCommand命令{
公共数据:RoleClaimEntryDataModel;
初始化():void{
super.setBody(这个数据);
}
}
@Injectable()
export class UpdateRoleClaimCommand extends BaseCommand<boolean> {
public data = RoleClaimEntryDataModel;
initialise(): void {
super.setBody(this.data);
}
}
@Injectable()
export class PermissionDataService{
constructor(
private updateRoleClaimCommand: UpdateRoleClaimCommand
){}
public UpdateRoleClaimById(roleClaimEntryDataModel: RoleClaimEntryDataModel)
{
this.updateRoleClaimCommand.data = roleClaimEntryDataModel; // throw error here
}
@Injectable()
export class UpdateRoleClaimCommand extends BaseCommand<boolean> {
public data: RoleClaimEntryDataModel;
initialise(): void {
super.setBody(this.data);
}
}