0

I am working on Angular 5 application. I have model class RoleClaimEntryDataModel and in one injectable service I have method 'UpdateRoleClaimById' receiving RoleClaimEntryDataModel as parameter and I am trying to assign this object to RoleClaimEntryDataModel of class but I get error

error

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

Model class

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

Injectable Service A

 @Injectable()
 export class UpdateRoleClaimCommand extends BaseCommand<boolean> {

  public data = RoleClaimEntryDataModel;

  initialise(): void {
      super.setBody(this.data);
  }
}

Injectable Service B

@Injectable()
export class PermissionDataService{

constructor(
    private updateRoleClaimCommand: UpdateRoleClaimCommand
){}

 public UpdateRoleClaimById(roleClaimEntryDataModel: RoleClaimEntryDataModel)
{
    this.updateRoleClaimCommand.data = roleClaimEntryDataModel; // throw error here
}

1 Answer 1

2

Because the data property in your UpdateRoleClaimCommand refers to the type RoleClaimEntryDataModel, not a variable of type RoleClaimEntryDataModel

This is how it should be

@Injectable()
 export class UpdateRoleClaimCommand extends BaseCommand<boolean> {

  public data: RoleClaimEntryDataModel;

  initialise(): void {
      super.setBody(this.data);
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.