I want to attach watch on order
. I am not sure how to add watch to variable inside list of dict.
Inside controller,
cart_list = [{'order':'single'},{'order':'single'},{'order':'twice'}];
for (var i = 0; i < $scope.cart_list.length; i++) {
$scope.$watch('cart_list[i].order', function() {
console.log("Inside watch");
if($scope.cart_list[i].order=='single'){
console.log("with single order");
}
}
}
This gives me error,
TypeError: Cannot read property 'order' of undefined