我是 angularjs 的初学者,遵循代码有什么问题,没有错误,但结果没有显示在视图中



//anular model

       var app = angular.module('myapp', []);

这是获取数据的服务

        app.service('EmployeeService', function ($http) {
            this.getEmployees = function () {
                return this.$http.get('Employee/getall');
            }
        });

角度控制器

        app.controller('EmployeeController', function ($scope, EmployeeService) {
            function getEmployeeList() {
                EmployeeService.getEmployeeList.then(function (emp) {
                    $scope.EmployeeList = emp.data;
                }, function (error) {
                });
            }
        });

控制器返回 JSON 结果

public JsonResult getall()
{
       List<Countries> contry = new List<Countries>() { 
       new Countries({id=1,Name="ahmad" ,LastName="ali" },
       new Countries() {id=1,Name="kami" ,LastName="ali" },
       new Countries() {id=1,Name="billo" ,LastName="ali" },
       new Countries() {id=1,Name="juni" ,LastName="ali" },
       new Countries() {id=1,Name="podeena" ,LastName="ali" }                            };
      return Json(contry, JsonRequestBehavior.AllowGet);
     }

这是视图

编号 名字 姓 {{e.id}} {{e.Name}} {{e.LastName}}

这些是链接

<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/angular-route.min.js"></script>
<script src="~/Angular/Module.js"></script>
<script src="~/Angular/Service.js"></script>
<script src="~/Angular/empController.js"></script>

小问题。您需要一个员工列表,但返回一个国家/地区列表对象。在线$scope.EmployeeList = emp.data $scope.EmployeeList = emp.country.在哪里显示员工列表的代码?是否在$scope点放置了断点。EmployeeList get设置以确保数据得到恢复。

相关内容

最新更新