Node JS と MAEN スタックは初めてです。MEANJS のチュートリアルに従って学習しています。このスクリーンキャストhttp://www.youtube.com/watch?v=HNpMCFB8TFI&list=PL6rhBJX0L3TWYrwrQIi1_MzQDvVhkUVPI&index=26で、新しい顧客を作成します。ただし、「オブジェクトは関数ではありません」というエラーメッセージが表示されるため、新しい顧客を作成できません。これは、Google Chrome のコンソールが示唆するように、この行「var customer = new Customers」を参照しています。ここにコードがあります
customersApp.controller('CustomersCreateController', ['$scope', '$stateParams', '$location', 'Authentication', 'Customers',
function($scope, Customers ) {
// Create new Customer
this.create = function() {
// Create new Customer object
var customer = new Customers ({
firstName: this.firstName,
surname: this.surname,
suburb: this.suburb,
country: this.country,
industry: this.industry,
email: this.email,
referred: this.referred,
phone: this.phone,
channel: this.channel
});
// Redirect after save
customer.$save(function(response) {
// Clear form fields
$scope.firstName = '';
$scope.surname = '';
$scope.suburb = '';
$scope.country = '';
$scope.industry = '';
$scope.email = '';
$scope.referred = '';
$scope.phone = '';
$scope.channel = '';
}, function(errorResponse) {
$scope.error = errorResponse.data.message;
});
};
}
]);
アップデート コントローラのアップデート機能は正常に動作することに注意してください。コードは次のとおりです。
customersApp.controller('CustomersUpdateController', ['$scope', '$stateParams', '$location', 'Authentication', 'Customers',
function($scope, Customers ) {
// Update existing Customer
this.update = function(updatedCustomer) {
var customer = updatedCustomer;
customer.$update(function() {
//wont do anything as the modal will be closed
}, function(errorResponse) {
$scope.error = errorResponse.data.message;
});
};
}
]);
私は本当にあなたの助けに感謝します、前もって感謝します