Hey everyone I'm extremely new to AngularJS and I have an issue with my ng-repeat showing blank table rows on the page. So, I'm calling a asmx web service to return a JSON Serialized string of simple work queue information. When I try to display it to a table on the page all the rows are blank.
WebService Method:
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void GetMainWorkQueueInformationJson(string userName, string status)
{
try
{
var info = incidentManagerDal.GetMainWorkQueueInformation(userName, status);
var json = JsonConvert.SerializeObject(info);
logger.Info("Gathered Working Queue Information.", new object[] { "Success" });
HttpContext.Current.Response.Write(json);
}
catch (Exception ex)
{
logger.Error(ex);
throw;
}
}
HTML Code:
<div>
<table>
<tr>
<th>IM#</th>
<th>Requirements Received Date</th>
<th>Planned Implementation Date</th>
<th>Dev Assigned</th>
<th>Title</th>
</tr>
<tr ng-repeat="x in queue track by $index">
<td>{{x.IMNumber}}</td>
<td>{{x.RequirementsReceivedDate}}</td>
<td>{{x.PlannedImplementationDate}}</td>
<td>{{x.DevAssigned}}</td>
<td>{{x.Title}}</td>
</tr>
</table>
</div>
Module/Controller js:
angular.module('myApp', []).controller('myCtrl', function ($scope, $http) {
$http.get('inserturl', {
params: { userName: "name", status: "working" }
}).then(function (response) {
console.log(response);
$scope.queue = response.data;
}).catch(function (response) {
console.error('Error occurred:', response.status, response.data);
}).finally(function () {
console.log("Task Finished.");
});
I'm not sure what I'm. Trying to understand the basics of calling webservices to get information from and displaying that data. Appreciate any help.
Update:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">[{"RequestID":1052,"IMNumber":"dsdsad","CMNumber":"","RequirementsReceivedDate":"2017-04-20T15:04:02.423","PlannedImplementationDate":"2017-04-20T15:04:02.423","DevAssigned":"name","Title":"dsadsada","Description":"dsadsadsa","Comments":"dsadsadsafdsfdsfdsfds","Status":"Working","RequestedBy":"requestname","DoesNotRequireCMR":null,"DeveloperTime":0},{"RequestID":1053,"IMNumber":"fdsfdsfds","CMNumber":"","RequirementsReceivedDate":"2017-04-20T15:04:39.75","PlannedImplementationDate":"2017-04-20T15:04:39.75","DevAssigned":"name","Title":"fdsfdsfdsfdsfdsfds","Description":"dsadsadsa","Comments":"dsadsadsadsa","Status":"Working","RequestedBy":"dsadsadsa","DoesNotRequireCMR":null,"DeveloperTime":999},{"RequestID":1054,"IMNumber":"dasdas","CMNumber":"","RequirementsReceivedDate":"2017-04-20T18:22:41.513","PlannedImplementationDate":"2017-04-20T18:22:41.513","DevAssigned":"name","Title":"dsadasdasda","Description":"dsadasdas","Comments":null,"Status":"Working","RequestedBy":"dsdasdasd","DoesNotRequireCMR":null,"DeveloperTime":0}]</string>
Update:
Modified webservice method to write directly back to remove the xml wrapping the json object.