I pass an object to a function. I pull out the property of an object, which is a helper object for easy reading. However, this second object does not affect a similar property for the first object. Why is this?
I want processItem.event outside the scope to be updated when the event is saved. Why update processItem, not just a local variable that points to this?
It works:
this.submitForm = function(processItem) {
var event = processItem.event
if (event.new) {
EventDataService.create(event).then(function(response) {
processItem.event = response.data;
});
} else {
EventDataService.update(event).then(function(response) {
processitem.event = response.data
});
}
};
and it is not
this.submitForm = function(processItem) {
var event = processItem.event
if (event.new) {
EventDataService.create(event).then(function(response) {
event = response.data;
});
} else {
EventDataService.update(event).then(function(response) {
event = response.data
});
}
};
source
share