Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular2从方法参数对象指定对象值_Angular_Typescript - Fatal编程技术网

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

Angular2从方法参数对象指定对象值,angular,typescript,Angular,Typescript,我正在处理Angular 5应用程序。我有模型类RoleClaimEntryDataModel,在一个可注入服务中,我有方法'UpdateRoleClaimById'接收RoleClaimEntryDataModel作为参数,我试图将此对象分配给类的RoleClaimEntryDataModel,但我得到错误 错误 模范班 可注入服务A 因为UpdateRoleClaimCommand中的data属性引用的是类型RoleClaimEntryDataModel,而不是类型RoleClaimEntr

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

错误 模范班 可注入服务A
因为
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);
  }
}