AngularJS watch array of objects for data change

后端 未结 3 1304
时光说笑
时光说笑 2020-11-30 05:27

I\'m implementing a shopping cart and want to store the data in localStorage. I want to watch the variable $scope.cart for change so that I can update the local

3条回答
  •  长情又很酷
    2020-11-30 06:19

    try to change

    $scope.$watch($scope.cart, $scope.updateCart(), true);
    

    to

    $scope.$watch('cart', $scope.updateCart(), true);
    

    $watch only evaluate string or function parameter in its first argument

提交回复
热议问题