custom created method error: “is not a function”

后端 未结 2 1915
被撕碎了的回忆
被撕碎了的回忆 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:34

    Your service most probably only returns plain objects, meaning they don't have the member methods of the Hero class.

    You need to explicitly create new Hero() objects to have the toggleState() method available on the hero object.

提交回复
热议问题