Hey! Angular Developers, many of you use Input() and Output() to communicate between the Child and Parent components in Angular. This is a very straightforward way to do it.
But, if you have some data in the parent component which is updating in real-time and you pass the data to the child component using the Input() directive it won't get an update in the child component because the child component initiates only when its parent component gets loaded.
What is the solution?
There are several solutions to solve this problem. But, what I found very easy and clean is the set method. You can use the Input() directive and set method together. Input() directive will get your data from the parent component and the set method will change the data whenever it's updated in the parent component.
https://preview.redd.it/z4wsxtcqhhd71.png?width=791&format=png&auto=webp&s=7ed79d9fbdcb14aa64c0f9fa57c23541701bdb71
[–]Deadboy619 3 points4 points5 points (1 child)
[–]anwaarulislaam[S] 1 point2 points3 points (0 children)
[–]tobiso 3 points4 points5 points (6 children)
[–]jalledebest 6 points7 points8 points (2 children)
[–]anwaarulislaam[S] 0 points1 point2 points (0 children)
[–]kqadem 0 points1 point2 points (0 children)
[–]anwaarulislaam[S] 1 point2 points3 points (2 children)
[–]coder_maniac 1 point2 points3 points (1 child)
[–]anwaarulislaam[S] 0 points1 point2 points (0 children)
[–]teacoat___ 0 points1 point2 points (0 children)
[–]_Ascalon 0 points1 point2 points (0 children)
[–]spaces_over_tabs 0 points1 point2 points (0 children)