As someone who is new to AngularJS and JSON, I am facing an issue when trying to filter out unnecessary fields in the JSON data.
In my controller, I have the following code snippet:
var data = $scope.choices; // This is an array
var datav = (JSON.stringify(data)); // Converting the array into a string for filtering
alert(datav);
When I use alert(datav)
, the JSON data displayed includes unwanted fields like $$hashKey
and id
:
[{"title":"g","$$hashKey":"object:3"},{"id":"choice2","$$hashKey":"object:6","title":"ghgh"},{"id":"choice3","$$hashKey":"object:11","title":"fgh"}]
I only want to extract the "title" field and exclude $$hashKey
and id
. How can I achieve this?