Angular ngresouce $update 不是函数
Angular ngresouce $update is not a function
我正在使用 angular xeditable 编辑字段并将其值更新到数据库,但它不起作用。它一直说 $update 不是函数。与 $save 相同,它是 POST。
不确定 ng-repeat 或 xeditable 是否正在造成范围界定问题,但通过 updateBusinessGoal 函数传递的对象带有已经更改的值,调用更新应该是所需要的。
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
}
}
})
对于有一天偶然发现这个的人来说,这是因为这是错误的语法。它应该很简单:
businessGoals.updateBusinessGoal = function(goal){
ServiceName.update(goal);
);
}
我正在使用 angular xeditable 编辑字段并将其值更新到数据库,但它不起作用。它一直说 $update 不是函数。与 $save 相同,它是 POST。
不确定 ng-repeat 或 xeditable 是否正在造成范围界定问题,但通过 updateBusinessGoal 函数传递的对象带有已经更改的值,调用更新应该是所需要的。
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
}
}
})
对于有一天偶然发现这个的人来说,这是因为这是错误的语法。它应该很简单:
businessGoals.updateBusinessGoal = function(goal){
ServiceName.update(goal);
);
}