Accessing Child Components from Template
In our templates, we may find ourselves needing to access values provided by the child components which we use to build our own component.
The most straightforward examples of this may be seen dealing with forms or inputs:
app/app.component.html
app/app.component.ts
This isn't a magic feature which only forms or inputs have, but rather a way of referencing the instance of a child component in your template. With that reference, you can then access public properties and methods on that component.
app/app.component.html
app/profile.component.ts
There are other means of accessing and interfacing with child components, but if you simply need to reference properties or methods of a child, this can be a simple and straightforward method of doing so.
Last updated