Angular pass callback function to child component as @Input similar to AngularJS way

后端 未结 10 1601
庸人自扰
庸人自扰 2020-11-27 10:22

AngularJS has the & parameters where you could pass a callback to a directive (e.g AngularJS way of callbacks. Is it possible to pass a callback as an @Input

10条回答
  •  -上瘾入骨i
    2020-11-27 10:51

    Use Observable pattern. You can put Observable value (not Subject) into Input parameter and manage it from parent component. You do not need callback function.

    See example: https://stackoverflow.com/a/49662611/4604351

提交回复
热议问题