From the course: Angular: Building an Interface

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Passing data to subcomponents

Passing data to subcomponents - Angular Tutorial

From the course: Angular: Building an Interface

Start my 1-month free trial

Passing data to subcomponents

- [Instructor] Now that we have our components setup, we need to figure out how to send the data that we received into this app component right here, by using this Http get command, and pass it along to a sub-component. We already know how to pass information from a component to its template, we do that just by creating a variable and then giving it some value, and then we use this expression notation, these double curly braces, and just put in the value of the variable here. So, what we need to do to take care of this is first create a variable that we can pass along into the sub-component. Now, I'm going to create that variable right here, and it's going to be called theList. And I'm going to give it a type of object array, because the data.json file happens to be an array of objects. So, once I do that, then I can go ahead and use it instead of this console.log. So I can can say now this.theList is equal to my data. That's going to complain because theList is tagged as an object…

Contents