我想編輯表中的一行數據。當我點擊該行時,它彈出所需的視圖,但它不能拉出相關數據進行編輯。任何人都可以嘗試找到問題。我猜它與$ routeParams和錶行的相關索引有關。加入了我的運動員。angularjs錶行編輯問題
app.controller("editController", ["$scope", "$location", "$routeParams", "listService", function($scope, $location, $routePartam, listService) { $scope.data = listService.getDepartments(); //$scope.id = $routeParams.id; //alert($route.current.params.id);
//alert("test"+ "$routeParams"); //$scope.Item=listService.getDepartments()[parseInt($routeParams.id)]; $scope.Item=listService.getDepartments()[0]; // saving an existing items $scope.save = function() { listService.editDepartments(0,{dialnumber:$scope.Item.dialnumber,department:$scope.Item.department,level:$scope.Item.level});
//listService.editDepartments(parseInt($routeParams.index),{dialnumber:$scope.Item.dialnumber,department:$scope.Item.department,level:$scope.Item.level}); //Saving code $location.path("/Items"); }; $scope.cancel = function() { $location.path("/Items");
};
http://plnkr.co/edit/ez0s66S9bmO0jt8Nb6BR?p=info
你應該格式化張貼您的代碼時,你就會有有人更好地掃描它並發現問題。 –