I want to create a simple CRUD app using angular on the frontend.
I'm not really happy with the logic here, it seems a bit convoluted for fairly simple functionality.
<div class = "container-fluid">
<div id = "table" class = "row" ng-repeat = "o in objects" ng-init = "o.isBeingEdit = false">
<div class ="col-xs-1"> {{o.objectId}}</div>
<input type = "text" ng-model = "o.someContent" class = "col-xs-9" ng-disabled = "!o.isBeingEdit"/>
<input type = "button" class = "col-xs-2 btn btn-default" ng-click = "editSave(o)" ng-value = "o.isBeingEdit? 'Save' : 'Edit'"/>
</div>
</div>
$scope.editSave = function(o){
if (o.isBeingEdit){
//Save
BackendService.updateObject(o).then(function(data){
o.isBeingEdit = false;
}, function(data){
o.isBeingEdit = false;
handleServerError(data);
});
}
else{
o.isBeingEdit = true;
}
};
Is there a much much much nicer way of doing this?