I'm needing some help with Angular Component method. I have a main html with its main controller, in which i have a JSON list of client data like:
clients: [{
"name": "John Jackson",
"age": "21",
"hair": "brown",
}, {
"name": "Janet Doe",
"age": "19",
"hair": "blond",
}]
I need to display all the client data in the main html so i thought i could use an Angular component (never used before). I created a html template for the component (using bootstrap btw), quite simple like:
<div class="row">
<label>Name: {{client.name}}</label>
<label>Age: {{client.age}}</label>
<label>Hair: {{client.hair}}</label>
</div>
So now i need to use a ng-repeat in the main.html, looping the clients. For each client in the list i need to add the row div of the component. Is this possible? As i need to pass the client info (EACH client, not the list) to the component, and this one has to return the html for each client.
In the examples i found, the component counts with the necessary information (client), but in my case that information is in the main controller, and i need to pass it to the controller (as they have different scopes).
The idea is the component to be called in different views.
If anybody could give me that first step (or a nice example of a similar situation) would be awesome.
Thanks a lot in advance!