custom created method error: “is not a function”

后端 未结 2 1916
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 11:23

I have a list of hero-buttons with a custom animation created in button.component.ts. At the beginning, they are inactive. When I press one of then, the selecte

2条回答
  •  感动是毒
    2021-01-13 11:50

    If you cast JSON to a TypeScript class, all is happening is that you indicate to the static analysis it can safely assume the value is of that class; that doesn't actually change the JSON value at all (i.e it doesn't make it an instance of that class).

    What you want is probably How do I cast a JSON object to a typescript class or Cast JSON object to TypeScript class instance

提交回复
热议问题