V0.1c Implementierung Form-Group für Eingabe der Zettel
This commit is contained in:
parent
2bf1483666
commit
0b7fbadd8b
@ -3,15 +3,29 @@
|
|||||||
<h2>Neuen Einkaufszettel Eintrag anlegen:</h2>
|
<h2>Neuen Einkaufszettel Eintrag anlegen:</h2>
|
||||||
|
|
||||||
<div class="form">
|
<div class="form">
|
||||||
|
<form novalidate (ngSubmit)="saveTask(form.value)" #form="ngForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Titel*</label>
|
||||||
|
<input type="text" class="form-control" name="title" id="title" #title ngModel required/>
|
||||||
|
|
||||||
<div class="control">
|
<label for="image">Bild-URL*</label>
|
||||||
<label for="title">Titel:</label>
|
<input type="text" class="form-control" name="title" id="image" #image ngModel required/>
|
||||||
<input type="text" id="title" #title/>
|
|
||||||
</div>
|
<label>Kategorie*</label>
|
||||||
<div class="control">
|
<input type="text" class="form-control" id="kategorie" #kategorie ngModel required/>
|
||||||
<label for="title">Bild-URL:</label>
|
|
||||||
<input type="text" id="image" #image/>
|
<label for="menge">Menge*</label>
|
||||||
|
<input type="text" class="form-control" name="title" id="menge" #menge ngModel required/>
|
||||||
|
|
||||||
|
<label for="kommentar">Kommentar: </label>
|
||||||
|
<textarea id="kommentar" #kommentar cols="20" rows="3" #text>
|
||||||
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<button (click)="createBlogEntry(title.value, image.value, kategorie.value,menge.value, kommentar.value)">
|
||||||
|
Blog-Eintrag anlegen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row custom-wrapper">
|
<div class="row custom-wrapper">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
@ -37,18 +51,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
|
||||||
<label for="title">Kategorie:</label>
|
|
||||||
<input type="text" id="kategorie" #kategorie/>
|
|
||||||
</div>
|
|
||||||
<div class="control">
|
|
||||||
<label for="text">Text:</label>
|
|
||||||
<textarea id="text" cols="20" rows="3" #text>
|
|
||||||
</textarea>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button (click)="createBlogEntry(title.value, image.value, kategorie.value, text.value)">
|
|
||||||
Blog-Eintrag anlegen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,18 +22,23 @@ export class AppComponent {
|
|||||||
isSubmitted = false;
|
isSubmitted = false;
|
||||||
// Kategorien
|
// Kategorien
|
||||||
Kategorien: any = ['Lebensmittel', 'Spielwaren', 'Technik', 'Sonstiges'];
|
Kategorien: any = ['Lebensmittel', 'Spielwaren', 'Technik', 'Sonstiges'];
|
||||||
/*########### Form ###########*/
|
|
||||||
|
/*########### Form ###########*/
|
||||||
registrationForm = this.fb.group({
|
registrationForm = this.fb.group({
|
||||||
kategorieName: ['', [Validators.required]]
|
kategorieName: ['', [Validators.required]]
|
||||||
});
|
});
|
||||||
|
saveTask(value: any){
|
||||||
|
console.log(value);
|
||||||
|
}
|
||||||
|
|
||||||
createBlogEntry(title: string, image: string, kategorie: string, text: string, ) {
|
createBlogEntry(title: string, image: string, kategorie: string, menge: string, kommentar: string, ) {
|
||||||
if (title && image && text && kategorie) {
|
if (title && image && kommentar && kategorie) {
|
||||||
const entry = new BlogEntry();
|
const entry = new BlogEntry();
|
||||||
entry.title = title;
|
entry.title = title;
|
||||||
entry.image = image;
|
entry.image = image;
|
||||||
entry.text = text;
|
|
||||||
entry.kategorie = kategorie;
|
entry.kategorie = kategorie;
|
||||||
|
entry.menge = menge;
|
||||||
|
entry.kommentar = kommentar;
|
||||||
this.entries.push(entry);
|
this.entries.push(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import {ReactiveFormsModule} from '@angular/forms';
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -12,6 +12,7 @@ import {ReactiveFormsModule} from '@angular/forms';
|
|||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
FormsModule,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
<div class="blog-summary">
|
<div class="blog-summary">
|
||||||
<span class="title">{{entry.title}}</span>
|
<span class="title">{{entry.title}}</span>
|
||||||
<p> {{entry.kategorie}}</p>
|
<p> {{entry.kategorie}}</p>
|
||||||
<p> {{entry.text}}</p>
|
<p> {{entry.kommentar}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,5 +2,7 @@ export class BlogEntry {
|
|||||||
title: string;
|
title: string;
|
||||||
image: string;
|
image: string;
|
||||||
kategorie: string;
|
kategorie: string;
|
||||||
text: string;
|
menge: string;
|
||||||
|
kommentar: string;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,14 @@ export const initialEntries = [
|
|||||||
title: 'Edeka',
|
title: 'Edeka',
|
||||||
image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Logo_Edeka.svg/1200px-Logo_Edeka.svg.png',
|
image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Logo_Edeka.svg/1200px-Logo_Edeka.svg.png',
|
||||||
kategorie: 'Lebensmittel',
|
kategorie: 'Lebensmittel',
|
||||||
text: 'Hier könnten ihre benötigten Einkäufe stehen'
|
menge: '1',
|
||||||
|
kommentar: 'Hier könnten ihre benötigten Einkäufe stehen'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Aldi Süd',
|
title: 'Aldi Süd',
|
||||||
image: 'https://www.horizont.net/news/media/20/Logo-Aldi-Sd-2017-198042-detailnp.jpeg',
|
image: 'https://www.horizont.net/news/media/20/Logo-Aldi-Sd-2017-198042-detailnp.jpeg',
|
||||||
kategorie: 'Lebensmittel',
|
kategorie: 'Lebensmittel',
|
||||||
text: 'Hier könnten ihre benötigten Einkäufe stehen'
|
menge: '1',
|
||||||
|
kommentar: 'Hier könnten ihre benötigten Einkäufe stehen'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user