javascript - Angular $update resource -
edit: if it's hard troubleshoot without me posting more code, allow me know , can add together more question.
i have 2 instances of same code, , 1 of them working while other isn't.
working fine:
$scope.update = function() { var question = $scope.question; question.$update(function() { $location.path('questions/' + question._id); }); };
not working:
$scope.updateanswer = function() { var reply = $scope.answeredited; answer.$update(function() { $location.path('questions/' + $routeparams.questionid); }); $scope.toggleeditanswer(answer); };
i error: undefined not function @ $update
function. here's resource:
angular.module('intquestapp') .factory('answers', function ($resource) { homecoming $resource('api/answers/:answerid', { answerid: '@_id' }, { update: { method: 'put' } }); });
what doing wrong? if understand flow correctly, answer.$update
uses resource somehow? also, if utilize console.log
view answer
beingness updated, right one:
resource {_id: "543d8896039390eb5e000001", created: "2014-10-14t20:33:26.514z", creator: object, questionid: "543d8693994fc1685d000001", __v: 0…}
how can troubleshoot this?
could seek next , check if works?
$scope.updateanswer = function() { answers.update($scope.answeredited, function(response) { $location.path('questions/' + $routeparams.questionid); }); $scope.toggleeditanswer(answer); };
javascript angularjs angular-resource
No comments:
Post a Comment