title: How to parse JSON array in AngularJS
body: <p>I was trying to parse JSON array in AngularJS. But it's not working. If the array is written directly it's working. Help me to solve the issue. The code I have been using is below. </p>
  
  <pre><code>(function () {
      var app = angular.module('store', ['ngCookies']);
  
      app.controller('StoreController', ['$scope', '$cookies', function ($scope, $cookies) {
          $scope.products = JSON.parse(SuccessItems);
          $scope.cart = [];
          $scope.total = 0;
          var expireDate = new Date();
          expireDate.setDate(expireDate.getDate() + 1);
          $cookies.putObject('cart', $scope.cart, { 'expires': expireDate });
          $scope.cart = $cookies.getObject('cart');
          $scope.total += parseFloat(product.price);
          $cookies.put('total', $scope.total, { 'expires': expireDate });
      };
      }]);
  
      var SuccessItems = '';
      $.ajax({
          type: "POST",
          url: "code.aspx/RetrieveItems",
          data: "{}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          async: false,
          success: function (jsondata) {
              SuccessItems = jsondata.d.replace(/"(\w+)"\s*:/g, '$1:').replace(/"(\d[.]\d+)"/g, "$1");
          },
          error: function (xhr, ajaxOptions, thrownError) {
              errMsg = JSON.parse(xhr.responseText).Message;
              alert(baseErrorMsg + 'Error Code : ' + errMsg);
          }
      })
  })();
  </code></pre>