我没有在$ scope.Attendancesdata中获取数据

时间:2016-04-13 11:09:35

标签: angularjs asp.net-mvc

我可以从Home / GetAllAttendanceData传递数据但是在控制器$ scope.Attendancesdata中无法访问data.my模块,服务和控制器代码如下所示。

## Home/GetAllAttendanceData ##
public JsonResult GetAllAttendanceData()
    {
         var bookList = db.Attendances.Where(x => x.Id == 1).ToList(); 
        return Json(bookList, JsonRequestBehavior.AllowGet);     
    }

 ## service.js ##
 app.service("crudAJService", function ($http) {
  this.getdata = function () {
    return $http.get("Home/GetAllAttendanceData");
};
});




## Module.js ##
var app = angular.module("myModule", []);



## Controller.js ##
app.controller("myController", function ($scope, crudAJService) {
debugger;
$scope.divBook = false;
GetAlldata();
function GetAlldata() {
    debugger;
    var getAttendanceData = crudAJService.getdata();
    getAttendanceData.then(function(Attendances) {
        $scope.Attendancesdata = Attendances.data;
    }, function () {
        alert('Error in getting book records');
    });
}
});

0 个答案:

没有答案