简体   繁体   English

如何在Angular的ngOnInit中使用Typescript访问器?

[英]How to use Typescript Accessors in ngOnInit in Angular?

I have a getter and a setter propertie, and I want to use that in the ngOnit of Angular. 我有一个getter和setter属性,我想在Angular的ngOnit中使用它。

The Typescript Accessors looks like this: 打字稿访问器看起来像这样:



         if (modelValue) {

    }

and I have the ngOnit like this: 我有这样的ngOnit:

ngOnInit(): void {

    }

and the constructor looks like this: 构造函数如下所示:



    }

But now I get this error: 但是现在我得到这个错误:


You don't an object for the pipe. 您不是管道的对象。

  constructor(readonly textResourceService: TextResourceService,readonly route: ActivatedRoute) {
    super(textResourceService, route);
    }

Should help. 应该有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM