I need to set array property in angular 6 with this code :
this.addupdate.roleids=this.selectedRole;
but it shows me this error :
ERROR TypeError: Cannot set property 'roleids' of undefined at AccessLevelComponent.push../src/app/admin/admin/dashboard/role/access-level/access-level.component.ts.AccessLevelComponent.AddRoleClaim (access-level.component.ts:60)
selectedRole:string[]=['1011','1010','1005'];
and my interface :
export interface IAddorupdateRole {
roleids:string[];
roleid:number;
}
this my code :
public AddRoleClaim(){
console.log("enter AddRoleClaim.Ts");
this.addupdate.roleids=this.selectedRole;
this.addupdate.roleid=this.roleId;
this.roleService.AddOrUpdateRoleCalim(this.addupdate).subscribe((data)=>
{
console.log("seccess" + data);
}
);
}
What's the problem ? how can I solve that?