我将Json字符串传递给Service Home / GetAllAttendanceData,我想在控制器中检索它。这是我的代码..
public JsonResult GetAllAttendanceData()
{
var ab = (from obj in db.Attendances where obj.Id==1 select new {EmpNTLogin = obj.EmpNTLogin });
return this.Json(ab,JsonRequestBehavior.AllowGet);
}
## Heading ##
angular.module('myModule', []).service("crudAJService", function ($http) {
this.getdata = function () {
return $http.get("Home/GetAllAttendanceData");
};
}).controller('myController', function ($scope, crudAJService) {
$scope.divBook = false;
GetAlldata();
function GetAlldata() {
debugger;
var getAttendanceData = crudAJService.getdata();
getAttendanceData.then(function (Attendances) {
$scope.Attendancesdata = Attendances.data
alert($scope.Attendancesdata);
}, function () {
alert('Error in getting book records');
});
}
});
我想在alert($ scope.Attendancesdata);
中显示字符串答案 0 :(得分:0)
也许你想要的是这个:
alert(JSON.stringify($scope.Attendancesdata));