I get JSON from a database and its structure is like this:
"data": [
{
"category": "1",
"description": "hello"
}
]
description
and category
are all dynamic, so I can have 5 objects with category:1
and 2 with category:3
etc. Or I could have 3 objects with category:20
and 25 objects with category:8
.
I want to create HTML elements like this:
Category 1
....
....
....
Category 3
....
....
I can create a string like this:
$scope.hello = [];
angular.forEach(data.data, function(value, key) {
$scope.hello.push(value.category+" "+value.description)
}
so that it will output:
Category 1 hello
Category 1 hi
Category 1 bye
Category 3 sup
Category 3 yo
But how will I turn this to:
Category 1
hello
hi
bye
Category 3
sup
yo