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

@@ -1,6 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { ODataModule } from 'odata-v4-ng';
import { AppRoutingModule } from './app-routing.module';
@@ -22,6 +23,7 @@ import { SongComponent } from './components/songs/song/song.component';
imports: [
BrowserModule,
BrowserAnimationsModule,
ReactiveFormsModule,
AppRoutingModule,
HttpClientModule,
ODataModule,

View File

@@ -1,7 +1,7 @@
table {
width: 100%;
border-radius: 8px;
//background: #fffe;
background: #fffe;
}

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;
}
}