Arrays 如何访问对象的子数组并将其推入父数组

Arrays 如何访问对象的子数组并将其推入父数组,arrays,angular,Arrays,Angular,我试图将子数组推送到父数组并检查子数组的值,我如何才能做到这一点或最好的方法来做到这一点 接口 export interface IErsaApps { app_id: number; app_type_id: number; app_name: string; app_roles: string; app_sort_id?: number; selectedApp: boolean;

我试图将子数组推送到父数组并检查子数组的值,我如何才能做到这一点或最好的方法来做到这一点

接口

export interface IErsaApps {
        app_id: number;
        app_type_id: number;
        app_name: string;
        app_roles: string;
        app_sort_id?: number;
        selectedApp: boolean;
        seletedAppRoleID?: number;
        roles: Array<IErsaAppRoles>;
}
export interface IErsaAppRoles {
    app_role_id: number;
    app_role_app_id: number;
    app_role_name: string;
    app_role_sort_id?: number;   
}
export interface IErsaPreviewApp {
    app_type_id: number;
    apps: Array<IErsaApps>;
}

如果要将对象推入
应用程序
(子)
数组
,可以通过以下方式执行:

this.iErsaPrevSelectedApps[1].apps.splice(0, 0, this.selectedObject);
注意事项:

按照您的示例使用索引1:
this.iErsaPrevSelectedApps[1]

在索引0处插入对象:
splice(0,0,this.selectedObject),但您可以根据需要进行调整

this.iErsaPrevSelectedApps[1].apps.splice(0, 0, this.selectedObject);