代码之家  ›  专栏  ›  技术社区  ›  K.Z

角度2从方法参数对象分配对象值

  •  0
  • K.Z  · 技术社区  · 7 年前

    我正在研究Angular5应用程序。我有模型类RoleClaimEntryDataModel,在一个可注入服务中,我有方法“updaterRoleClaimByID”接收RoleClaimEntryDataModel作为参数,我正试图将此对象分配给类的RoleClaimEntryDataModel,但我得到了错误

    错误

    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
    }
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Ivan Mladenov    7 年前

    data UpdateRoleClaimCommand RoleClaimEntryDataModel

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