edit song form

This commit is contained in:
Benjamin Ifland
2019-03-24 15:09:22 +01:00
parent af4493ec94
commit 915caf23b0
3 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
import { Song } from 'src/app/models/song.model';
import { SongsService } from 'src/app/data/songs.service';
import { Injectable } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
@Injectable({
providedIn: 'root'
})
export class EditSongService {
constructor(private songService: SongsService) { }
public initEditForm(song: Song): FormGroup {
const form = new FormGroup({
ID: new FormControl(song.ID),
Number: new FormControl(song.Number),
Name: new FormControl(song.Name, Validators.required),
Text: new FormControl(song.Text),
SongType: new FormControl(song.SongType, Validators.required),
Key: new FormControl(song.Key),
Tempo: new FormControl(song.Tempo)
});
return form;
}
}