learning-ionic / Chapter-8

Building a Messaging App
https://www.packtpub.com/application-development/learning-ionic
11 stars 18 forks source link

More issue! SyntaxError: JSON Parse error: Unexpected identifier "object" #3

Open hughred22 opened 9 years ago

hughred22 commented 9 years ago

So on your ChatDetailCtrl, you have $scope.chatToUser = $stateParams.otherUser; $scope.chatToUser = JSON.parse($scope.chatToUser);

It return error: SyntaxError: JSON Parse error: Unexpected identifier "object"

I try to do console.log ($stateParams.otherUser) and it return [object object] which I can not open it in console. No idea what kind of object it is. And I never see to pass object like this in stateParam. The usage is new to me and I can not find any doc to explain passing object like this. Please explain.

arvindr21 commented 9 years ago

To open an object in the console you can do console.log(JSON.stringify($stateParams.otherUser)). This is the place where one state sends data to another state. If you pass in an object in the first one, you should receive an object here. Can you check that?