Reputation: 2795
I am trying to style the JSON message to the required style.
the required style of JSON message looks like:
[
{
“question”: “Write down Nhat’s email”,
“answer”: “[email protected]”,
“inline”: true
},
{
<% NEXT QUESTION/ANSWER %>
},
{
<%…%>
}
]
and currently my JSON message looks like:
[{"Question":"Question","Note":"","notePlaceholder":"enter text","inlineChecked":false},{"Question":"Question","Note":"","notePlaceholder":"enter text...","inlineChecked":""}]
Any idea on that?
Upvotes: 1
Views: 209
Reputation: 42497
You could use the json
filter on the object in a pre
tag.
<pre>{{json | json}}</pre>
Regarding your question, you could add a $watchCollection
on json
, and in the handler iterate through the items and delete the property you don't want.
$scope.$watchCollection('json', function(values) {
angular.forEach(values, function(item) {
delete item.notePlaceholder;
});
});
Note, you're simply passing a reference from $scope.items
to $scope.json
, so if you modify one it will modify the other. If you don't want that, use angular.copy
to make a separate copy. I've also update the plunk.
Upvotes: 1