I'm trying to pass a group of counts as an object through a one way binded variable and am getting an infinite digest because the method I'm binding to the component with is returning a new object every time. Here's the example:
In parent component template:
<some-component counts="$ctrl.selectedCounts()"></some-component>
Parent component definition:
angular.module().component('parentComponent', {
controller() {
return {
selectedCounts() {
return {
[this.selectedThing1.length > 1 ? 'thing' : 'things']: this.selectedThing1.length,
[this.selectedThing2.length > 1 ? 'thing' : 'things']: this.selectedThing2.length,
}
}
}
}
})
How can I bind this counts
binding such that it doesn't create an infinite digest without mutating an object in the parent component and passing that to some-component
? I've tried using =*
as the binding in some-component
and while yes it doesn't create an infinite digest cycle, but it also doesn't propagate changes to the child component then for some reason.
Here's a fiddle that has that same infinite digest: http://jsfiddle.net/joshdmiller/HB7LU/