Reputation: 317
I am using angular xeditable to edit a field and update its value to the database but it isn't working. It keeps saying $update is not a function. Same with $save which is a POST.
Not sure if ng-repeat or xeditable is creating a scoping issue but the object being passed through the updateBusinessGoal function comes through with the value already changed and calling an update should be all that is needed.
HTML
<tr ng-repeat="goal in businessGoals.occupancyGoals | orderBy:'timeframe'">
<td class="capitalize">{{goal.timeframe}}</td>
<td>{{goal.current_value | number:0}}%</td>
<td><a href="#" blur="sumbit" onaftersave='businessGoals.updateBusinessGoal(goal)' buttons="no" editable-text="goal.threshold">{{goal.threshold || 'empty'}}%</a></td>
</tr>
JS
businessGoals.updateBusinessGoal = function(goal){
goal.$update({
user_business_goal_id: goal.user_business_goal_id,
type: goal.type,
timeframe: goal.timeframe,
threshold: goal.threshold}
);
}
return $resource(ENV.web_api_url + ENV.api_version + '/user/business_goals/:user_business_goal_id', {}, {
update: {
method: 'PUT',
params: {
user_business_goal_id: '@user_business_goal_id',
type: '@type',
timeframe: '@timeframe',
threshold: '@threshold'
},
headers: {
"X-Auth-Token": $window.sessionStorage.token
}
}
})
Upvotes: 0
Views: 1087
Reputation: 317
For anyone who stumbles upon this some day it is because this is bad syntax. It should be as easy as:
businessGoals.updateBusinessGoal = function(goal){
ServiceName.update(goal);
);
}
Upvotes: 2