I was wondering how I could convert something like:
$scope.foo = [
{name: "foo1", information : "bar1" },
{name: "foo2", information : "bar2" }
]
into a JSON string? I searched Stack Overflow earlier for this question and was advised to use angular.toJson(obj, pretty) which I also researched on their website, but I wasn't able to successfully do it.
JSON.stringify($scope.foo)?angular.toJson($scope.foo, true)should work fine. What errors did you get? Alsoangular.toJson($scope.foo)would work sinceprettyis optional