Reputation: 114
for passing data between angular's components is better to have many attributes or use services? Is better this:
app.component("name",{
bindings:{
data:'<'
}
})
Or this:
app.component("name",{
bindings:{}
controller: function(myService){
this.data= myService.data;
}
})
Upvotes: 1
Views: 26
Reputation: 237
I like to structure my apps so that the service is the source of the data and bindings should pass the data from the receiving component down to its children. Any sibling components can also receive that data directly from the service, but child components should have the data passed down through the bindings, not directly from service.
Upvotes: 1