Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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 Typescript | Decorator似乎没有正确注册_Angular_Typescript_Decorator - Fatal编程技术网

Angular Typescript | Decorator似乎没有正确注册

Angular Typescript | Decorator似乎没有正确注册,angular,typescript,decorator,Angular,Typescript,Decorator,我目前在Angular中使用Typescript装饰程序时遇到问题 我正在尝试制作一个简单的装饰器,您可以指定控件的输入类型或选择选项等,其背后的想法是我能够仅从模型构建表单 export class UserForm { @Input('text') @Required() firstName: string; @Input('text') @Required() lastName: string; } 所需的decorator工作得非常完美

我目前在Angular中使用Typescript装饰程序时遇到问题

我正在尝试制作一个简单的装饰器,您可以指定控件的输入类型或选择选项等,其背后的想法是我能够仅从模型构建表单

export class UserForm {
    @Input('text')
    @Required()
    firstName: string;

    @Input('text')
    @Required()
    lastName: string;
}
所需的decorator工作得非常完美,我对它绝对没有任何问题,但不管出于什么原因,@Input指令deosn似乎不起作用。我知道名称与Angulars输入冲突,但我100%确保使用正确的名称。目前我有一个非常基本的装饰师

export const Input = (inputType: string) => {
    return (): PropertyDecorator => {
        return (target: object, propertyKey: string) => {
            console.log(inputType, target, propertyKey);
        };
    };
};
每当我这样做时,我都会得到以下错误

“Input”文本接受的参数太少,无法在此处用作修饰符。你是想先打电话给它,然后写“@Input”文本吗

我真的不知道为什么会发生这种情况,我试着在文件顶部插入一个函数,而不是导出

同样值得一提的是,这是在Angle library设置中完成的,我确实在某个地方读到过,这和打字有关,但我不太确定,因为这是必需的工作