У меня проблема с некоторым из моего среднего кода стека. Код показан ниже вместе с ошибкой, которую я получаю. У кого-нибудь есть предложения. Кажется, это простая ошибка объявления, но я не могу найти решение
customersApp.controller('CustomersUpdateController', ['$scope', 'Customers', '$log',
function($scope, Customers, $log) {
// Update existing Customer
this.update = function(updatedCustomer) {
var customer = updatedCustomer;
customer.$update(function() {
$log.info('Made it inside ok');
//Dont want to take user anywhere else
// $location.path('customers/' + customer._id);
}, function(errorResponse) {
$scope.error = errorResponse.data.message;
});
};
}
]);
Это ошибка:
TypeError: Cannot read property '$update' of undefined
at update (http://localhost:3000/modules/customers/controllers/customers.client.controller.js:115:12)
at http://localhost:3000/lib/angular/angular.js:10880:21
at http://localhost:3000/lib/angular/angular.js:10655:29
at http://localhost:3000/lib/angular-touch/angular-touch.js:441:9
at Scope.$eval (http://localhost:3000/lib/angular/angular.js:12788:28)
at Scope.$apply (http://localhost:3000/lib/angular/angular.js:12886:23)
at Scope.$delegate.__proto__.$apply (<anonymous>:855:30)
at HTMLButtonElement.<anonymous> (http://localhost:3000/lib/angular-touch/angular-touch.js:440:13)
at http://localhost:3000/lib/angular/angular.js:2853:10
at forEach (http://localhost:3000/lib/angular/angular.js:325:18)
Я также получаю сообщение об ошибке {Uncaught TypeError: Cannot read property 'getToggleElement' of null} при загрузке страницы.