0
我正在构建一个地址簿,用户可以在点击它们时编辑字段。我发现这个提琴通过一个线程: http://jsfiddle.net/timriley/GVCP2/带有可点击字段的可点击表单
但它不解释如何处理与JSON样式的数据源。作为Angularjs一个初学者,我努力寻找绑定编辑表格数据模型的方式,所以我尝试是相当差:
function ClickToEditCtrl($scope) {
$scope.contacts = [
{
"id": 1,
"Name": "Betty",
"Surname": "Smith",
"Address": "24 Funny Avenue, wc149m, London, United Kingdom"
},
{
"id": 2,
"Name": "Anabella",
"Surname": "Vicks",
"Address": "19 Euston Road n12clm, London, Isle of Man"
}];
$scope.editorEnabled = false;
$scope.enableEditor = function() {
$scope.editorEnabled = true;
$scope.editableAddress = $scope.contacts.Address;
};
$scope.disableEditor = function() {
$scope.editorEnabled = false;
};
$scope.save = function() {
$scope.contacts = $scope.editableAddress;
$scope.disableEditor();
};
}
如何使所有的字段可以编辑和更新中JSON数组?