Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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 从字符串数组中获取类的keyof_Angular_Typescript_Angular Forms - Fatal编程技术网

Angular 从字符串数组中获取类的keyof

Angular 从字符串数组中获取类的keyof,angular,typescript,angular-forms,Angular,Typescript,Angular Forms,我有一个字符串数组,它是动态的,不是常量 此数组包含类属性的名称 export class MyClass { name: string, surname: string } 我想要一个返回这个数组的键的函数,比如 getKeyOf(columns: string[]): (keyof MyClass)[] { ... } 你的意思是这样的吗?谢谢,我从你的例子开始,但是比代码简单。我必须强制转换到(MyClass的键)[]数组

我有一个字符串数组,它是动态的,不是常量

此数组包含类属性的名称

export class MyClass {
    name: string,
    surname: string 
}
我想要一个返回这个数组的键的函数,比如

getKeyOf(columns: string[]): (keyof MyClass)[] {
...
}

你的意思是这样的吗?谢谢,我从你的例子开始,但是比代码简单。我必须强制转换到(MyClass的键)[]数组