My schema is as below.
Orders {
customers[{
customerId: String,
address: String,
onlineOrder [{
items...
}],
directOrder [{
items...
}]
}]
}
Now, for some reason(too big to explain) I want a watch function, for any items added to onlineOrder[items] array.
For that, I couldnot write the function like,
$scope.$watch('order.customer[i].onlineOrder[j]')
where i and j are array indices.
Because I want the watch function to be triggered for the current 'i'th customer, for every add/delete/modify of 'j'th online order item
I need help in this.
$watchin that case. - But I'd say take a look at$watchCollectionpossibly, not sure if it would work for you though in this case.$scope.$watch('order.customer[i].onlineOrder[j]', callback, true)work? Whenever you add (undefined->something), delete (something->undefined), modify (something->something else) there is a change and watch will notice... you have to include thetrueat the end though otherwise the watch function may not notice the latter case unless the object is completely exchanged.