Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys.

I need your help.

I wanna loop a json file in angularjs.
So far so good.
No Problem.

But now i have a problem :)

What I have tried:

The http call is:

$http({
		method: 'GET',
		url: 'url'
	})
	.then(function successCallback(response){
		
		$scope.UserObject = response.data;
	}, function errorCallBack(response){console.log('error: ' + response);});



my json file is:

<pre>{
  "Firstname": "Me",
  "Lastname": "Windy",
  "EMail": "me.windy@shiny.com",
  "Phone": "0110110111"
}


and my html code is:

<p ng-repeat="obj in UserObject">
	{{ obj.Firstname }}
	</p>


With {{ obj.Firstname }} i get no text. it´s empty.
if i list it with {{ obj }} i get all entrys.

the webservice is a c# webservice (Asmx) and i convert the jsonstring wie newtonsoft.

the json file is valid. but i dont understand why i can´t choose {{ obj.Firstname }}.

thanks m8ts.
Posted
Updated 21-Nov-18 11:38am
Comments
Bryian Tan 21-Nov-18 14:25pm    
the JSON might not valid, how the output look like with {{ obj }}?

1 solution

Possible the JSON file is incorrect.

Here is an example using JSON string

Load JSON data in angularjs - JSFiddle[^]

Here is an example reading JSON content from URL
Load JSON data in angularjs - JSFiddle - URL [^]

Compare the two JSON object with the one produce by your application, it might give you some clue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900