I am trying to push an array of string into an array of object --> Accessright[];
selectedAccessRights: String[];
accessRights: Accessright[];
for (var i = 0; i < this.numOfPages; i++) {
this.selectedAccessRights.push(this.selectedPages[i].entityName);
//I have tried to the following as well, but it doesn't add everything to the accessRights object. Only the last element
//this.accessRights[i].entityName = this.selectedPages[i].entityName;
}
this.accessRights = this.accessRights.push(this.selectedAccessRights);
But the above line gives me an error
Argument of type '
String[]' is not assignable to parameter of type 'Accessright'. Type 'String[]' is missing the following properties from type 'Accessright':accessRightId,entityName,entityAttribute
Also tried add and insert from other post but didn't work for me.
Honestly out of ideas and debugged for so long. Would appreciate if anyone can take a look.
Update:
38: //Accessright response format
accessGroup: {accessGroupId: 1, accessGroupName: "AdminGroup", accessRights: Array(0), staffs: Array(0)}
accessRightId: 39
entityAttribute: ["charts"]
entityName: "EditDashboard"
__proto__: Object
39: Array(12) //My array
0:
accessRightId: 0
entityName: "Staff"
isDisabled: undefined
1:
accessRightId: 1
entityName: "AccessGroup"
isDisabled: undefined
__proto__: Object
Tried the any[] method but it's not working as my webservices is expecting an access right object.
Accessrighttype.selectedAccessRights: String[]=[]see the =[] else the array is null