0

I have a var called $scope.informationData and the contents (as output by console.log) is like this:

{"completed":100,"pending":50,"defects":20,"overdue":10}

If I, in my HTML, use this though:

<div class="huge">{{ informationData.overdue }}</div>

Then it's empty. I don't think there's anything wrong with the binding though because if I do {{ informationData }} then it outputs the same JSON as above.

I think I'm just using the wrong syntax to read the data - what do I need to change informationData.overdue to in order to see the number 10 appear?

3
  • change your json like this:: {"completed":"100","pending":"50","defects":"20","overdue":"10"} Commented Oct 19, 2015 at 4:46
  • It's working plnkr.co/edit/1JwgXFFPoFSqAWuMPAIp?p=preview Commented Oct 19, 2015 at 4:47
  • what you get when printing whole object {{ informationData }} ? Commented Oct 19, 2015 at 4:50

2 Answers 2

1

Deserialize the json

$scope.informationData = angular.fromJson($scope.informationData);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this fixed it.
0

You should put your value in quotes not your keys. Change your json like this::

{"completed":"100","pending":"50","defects":"20","overdue":"10"}

Or

{completed:"100",pending:"50",defects:"20",overdue:"10"}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.