Reputation: 449
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.
Upvotes: 0
Views: 2305
Reputation: 5233
You are adding the comment in... the comment!
comment.push(comment);
This creates a circular reference.
Maybe you want to do:
comments.push(comment)
?
Upvotes: 1