in my angular application I want to use an array of object of id and role in below manner
let userRole: Array<...> = [
{ id: 1, name: 'Admin' },
{ id: 2, name: 'Super Admin' },
{ id: 2, name: 'User' },
{ id: 2, name: 'Watcher' }
];
BUT I am confused what need to fill up in place of ... ?
Array < Object > or Array <Any>
Trial 1 :
var role = {
id: number;
name: string;
};
and then Array <role> but it gives error
Trial 2 : adding with different class file
role.ts
export class Role {
constructor(
public id: number,
public name: string
) { }
}
and add in my file as
import { Role } from './role';
export class HeroFormComponent {
let userRole: Array<Role> = [
{ id: 1, name: 'Admin' },
{ id: 2, name: 'Super Admin' },
{ id: 2, name: 'User' },
{ id: 2, name: 'Wacher' }
];
But gives error
Error: SyntaxError: Unexpected strict mode reserved word