Uncertain of the specific details you wish to modify, but in relation to $scope.title
, this solution should suffice
//////////////////update(task, $data, 'title')
$scope.update = function(model, data, key){
//model === $scope.model, because passed like param
model[key] = data;
};
What does model[key] = data;
signify?
When dynamically configuring properties, you cannot execute it in that manner
var obj = {}; obj.'title' = "hello";
However, you can achieve the desired outcome using this approach
var obj = {}; obj['title'] = "hello";
As long as your model is an object (like obj in the example), the ['key']
will reference a property, not an index.