Sharing Data between Components in Angular
Fully documented lesson at In this episode, I am going to show you four different ways to share data between Angular components. Parent to Child the Input Decorator When you declare a variable with the Input decorator in the child component, it allows that variable to be received from a parent template. In this case, we define a message variable in the parent, then use square brackets to pass the data to the child. Now the child can display this data in its own template. Child to Parent via ViewChild ViewChild allows a one component to be injected into another, giving the parent access to its attributes and functions. One caveat, however, is that child won t be available until after the view has. .., angular, angular4, angular2, webdev, appdevelopment, typescript, javascript, lesson, tutorial 20170430 I317BhehZKM
|