0

var app = angular.module('app',['ngStorage']);

app.controller('myController', ['$scope','$localStorage', function($scope, $localStorage){
 var comment = [
  { name : '',
   rating : ''
  }
 ]
 $scope.saveData = function (review) {
  comment.push(comment);
  localStorage.setItem("review", JSON.stringify(comment));
  console.log("dkfjhdjhgjh",review); 
 };
 
}])

When I am Inserting through Input Box I am getting TypeError.

  • 2
    Where is the input box – Sajeetharan Feb 10 '17 at 18:20
  • Possible duplicate of [Chrome sendrequest error: TypeError: Converting circular structure to JSON](http://stackoverflow.com/questions/4816099/chrome-sendrequest-error-typeerror-converting-circular-structure-to-json) – Sajeetharan Feb 10 '17 at 18:20

1 Answers1

1

You are adding the comment in... the comment!

comment.push(comment);

This creates a circular reference. Maybe you want to do: comments.push(comment) ?

Thierry
  • 5,133
  • 3
  • 25
  • 30