Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 在角度视图中使用接口创建对象数组_Angular - Fatal编程技术网

Angular 在角度视图中使用接口创建对象数组

Angular 在角度视图中使用接口创建对象数组,angular,Angular,我想初始化一个内部有一个对象的数组 然后,使用一个函数,我希望能够将一个空对象推到它上面,甚至在以后删除一个对象 因此,我创建了一个与对象中的值相关的接口 export class Session { constructor( public genre: string, public ordre_interface: number, public nb_serie: number ) {} myObject = {} as Se

我想初始化一个内部有一个对象的数组

然后,使用一个函数,我希望能够将一个空对象推到它上面,甚至在以后删除一个对象

因此,我创建了一个与对象中的值相关的接口

export class Session {
    constructor(
      public genre: string,
      public ordre_interface: number,
      public nb_serie: number
  
    ) {}

    myObject = {} as Session;

}
然后在我的main.ts文件中,我导入这个接口并初始化我的数组

import {Session} from './session.model';

session = [] as Array<Session>;
但首先,当我初始化数组会话时,我希望里面有一个空对象,就像我得到一个空数组[]:

session = [
{
genre: '',
ordre_interface: null,
nb_serie: null,
}
];
第二,在我的函数中,我的代码在let ses=new Session()行上给出了错误:

我希望它创建一个新对象并将其放入数组中,如下所示:

session = [
{
genre: '',
ordre_interface: null,
nb_serie: null,
},
{
genre: '',
ordre_interface: null,
nb_serie: null,
}
];
导出类会话{
公共体裁:字符串;
公共命令界面?:编号;
公共nb_系列?:编号;
构造函数(){}
}
 Expected 3 arguments, but got 0
session = [
{
genre: '',
ordre_interface: null,
nb_serie: null,
},
{
genre: '',
ordre_interface: null,
nb_serie: null,
}
];