Ich benutze Winkel-Fullstack-Generator.Probleme beim Übergeben _id-Parameter in Login.Controller
Ich habe Probleme mit der Weitergabe von _id-Parameter an eine Funktion. Was ich versuche zu erreichen, nachdem ich einen Benutzer erstellt Ich möchte weitere Daten im Schema erstellen Referenzierung auf die Benutzer-ID
also hier ist mein Code
'use strict';
class SignupVendorController {
//end-non-standard
constructor(Auth, $state, $http) {
this.Auth = Auth;
this.$state = $state;
this.$http = $http;
this.submitted = false;
}
//start-non-standard
register(form) {
this.submitted = true;
if (form.$valid) {
this.Auth.createUser({
firstName: this.user.firstName,
lastName: this.user.lastName,
email: this.user.email,
password: this.user.password,
role: 'vendor'
})
.then(Auth => {
this.vendor = Auth.getCurrentUser;
this.createVendor(this.vendor._id);
console.log('user is ' + this.vendor.firstName);
console.log('vendor created');
// Account created, redirect to home
this.$state.go('main');
})
.catch(err => {
err = err.data;
this.errors = {};
// Update validity of form fields that match the mongoose errors
angular.forEach(err.errors, (error, field) => {
form[field].$setValidity('mongoose', false);
this.errors[field] = error.message;
});
});
}
}
createVendor(id) {
var vendor = {
category: ['publishing'],
_owner: id
}
this.$http.post('/api/vendors', vendor);
}
}
angular.module('aApp')
.controller('SignupVendorController', SignupVendorController);
ich mehrere Syntax Modifikation versucht haben, aber es ist alles nur undefined Variable auf diesem.Vendor.
wie dies zum Beispiel
var vendor = Auth.getCurrentUser;
console.log('the user is ' + vendor.firstName);
der Code nicht entweder _id oder Vornamen lesen. Jede Art von Hilfe würde sehr geschätzt werden. Vielen Dank!