angularjs表格行编辑问题

angularjs表格行编辑问题,angularjs,Angularjs,我试图编辑表中的一行数据。当我单击该行时,它会弹出所需的视图,但它无法提取相关数据进行编辑。有人能找出问题所在吗。我猜它与$routeParams和表行的相关索引有关。我的扑克牌又加了一句 app.controller(“editController”、[“$scope”、“$location”、“$routeParams”、“listService”、函数($scope、$location、$RouteParam、listService){$scope.data=listService.ge

我试图编辑表中的一行数据。当我单击该行时,它会弹出所需的视图,但它无法提取相关数据进行编辑。有人能找出问题所在吗。我猜它与$routeParams和表行的相关索引有关。我的扑克牌又加了一句

app.controller(“editController”、[“$scope”、“$location”、“$routeParams”、“listService”、函数($scope、$location、$RouteParam、listService){$scope.data=listService.getDepartments();//$scope.id=$routeParams.id;//警报($route.current.params.id);
//警报(“测试”+“$routeParams”);//$scope.Item=listService.getDepartments()[parseInt($routeParams.id)];$scope.Item=listService.getDepartments()[0];//保存现有项目$scope.save=function(){listService.editDepartments(0,{dialnumber:$scope.Item.dialnumber,department:$scope.Item,level:$scope.Item.level});
//listService.editDepartments(parseInt($routeParams.index),{dialnumber:$scope.Item.dialnumber,department:$scope.Item.department,level:$scope.Item.level});//保存代码$location.path(“/Items”);};$scope.cancel=function(){$location.path(“/Items”);

}
你差一点就搞定了……这是个打字错误:

  function($scope, $location, $routePartam, listService) {
看到了吗?它说的是
$routePartam
,或者
$routeParams
,所以editController的代码可能是这样的,请检查第一行:

  function($scope, $location, $routeParams, listService) { 
    $scope.data = listService.getDepartments();
    //$scope.id = $routeParams.id;

    //alert($route.current.params.id);

    //alert("test"+ "$routeParams");
   //$scope.Item=listService.getDepartments()[parseInt($routeParams.id)];
   var id = $routeParams.id;  

    $scope.Item=listService.getDepartments()[id];
    // saving an existing items
    $scope.save = function() {
      listService.editDepartments(id,{dialnumber:$scope.Item.dialnumber,department:$scope.Item.department,level:$scope.Item.level});      

查看修复程序:

您应该在发布时格式化代码,这样您就有更好的机会让别人浏览代码并发现问题。非常感谢您……我没有意识到有错别字