Need to load a Json in a table through ng-repeat

Hi,

I am using angularjs with grunt.I am a beginner

Have a table in html file.
PTDetails.html

<tr ng-repeat="project in PTList">

Through WCF i have the Json.
PTDetails.js

var promise = PTdata.getPTdata();

PTdata.js

this.gePTdata = function()
	{
		var deferred = $q.defer();
		var promise = this.LoadProject(); //Here I get the JSON
		promise.then(function(data) {					
				PTDataFromDB = data.userDetails; // Have the values in PTDataFromDB 					
			});
		return deferred.promise;
	}

This is what I have. I need to assign the JSON value in “PTDataFromDB” to “PTList” in the html page. I am trying this but not able too.

-Anto

Can you post enough code that we can recreate your problem.
You can stub out the promise variable with whatever the LoadProject function should return.

Hi Pullo,

The LoadProject function works fine and get the JSON value. Even though will post it.

this.LoadProject = function () {
		var deferred = $q.defer();			
		$http({
				method: 'POST',						
				url : "http://localhost-url",					
				dataType: "json",
				processData: true,
				headers: {'X-API-KEY': PTid()}//PTid is the Id send as parameter x-api-key
			}).success(function(data) {
				deferred.resolve(data);
				
			 }).error(function(msg, code) {
				// This will happen if this is a server side error.
            	deferred.resolve("Server error while trying to login. Please try again." + "Message : " + msg + "Code : " + code);					
			});
		return deferred.promise;
    };

Need the assign the JSON to the table. So think so need to convert the JSON to array or something. I am not sure. Any idea about it.

-Anto

If you provide enough code to recreate your problem then I don’t mind having a look.

To give you an idea of what I mean, have a look at this post. Here, I can just copy the code (from index.html) to my PC and run the demo. Something similar would be nice here.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.