Answer the question
In order to leave comments, you need to log in
How to automatically assign a record the ID of the user who creates it?
There are such models;
user.model:
export class User{
constructor(
public id?:number,
...
) { }
}
export class Notepad{
constructor(
public id?:number,
public user_id?:number,
public title?:string,
public description?:text
) { }
}
<form #notepadForm='ngForm'>
<div class="row">
<label>Наименование</label>
<input type="text" id="title" #title='ngModel' [(ngModel)]='notepad.title' name="title" >
</div>
<div class="row">
<label>Заметка</label>
<textarea type="text" [(ngModel)]="notepad.description" id="description" name="description" #description></textarea>
</div>
</form>
<button type="submit" (click)="saveNotepad(notepads)">Создать</button>
saveNotepad(notepads: Notepad) {
this.servNotepad.createNotepad(this.notepda).subscribe(
data => {
console.log(data);
}
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question