I have this Schema:
const userSchema = new Schema({
email: String,
skills: {
name: String,
label: String
}
})
module.exports = mongoose.model('user', userSchema, 'users')
Using ng-select in HTML like this:
<ng-select [items]="options" bindLabel="label" bindValue="value"
[addTag]="addCustomSkill" [multiple]="true"
placeholder="Select Skills" [(ngModel)]="registerUserData.skills"
name="skills">
</ng-select>
And I want to Post to mLab like this:
registerUser() {
this._auth.registerUser(this.registerUserData)
.subscribe(
res => console.log(res),
err => console.log(err)
)
}
Console will log the email but not the skills..
and, of course, mLab will put only the email
Update:
I managed to make it work by changing the skills to
skills: Array,
and:
name="skills[]"
But it will post without key the subarray, only the value like:
"skills": [
"JAVA"
],
I want it to be:
"skills": [
"name": "JAVA"
"label": "JAVA"
],