Browse Source

V0.1c Implementierung Form-Group für Eingabe der Zettel

master
Christian Greif 4 years ago
parent
commit
d5640df25a

+ 21
- 21
src/app/app.component.html View File

<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="title">Titel:</label>
<input type="text" id="title" #title/>
</div>
<div class="control">
<label for="title">Bild-URL:</label>
<input type="text" id="image" #image/>
<label for="image">Bild-URL*</label>
<input type="text" class="form-control" name="title" id="image" #image ngModel required/>

<label>Kategorie*</label>
<input type="text" class="form-control" id="kategorie" #kategorie ngModel required/>

<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">
</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>

+ 9
- 4
src/app/app.component.ts View File

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, ) {
if (title && image && text && kategorie) {
createBlogEntry(title: string, image: string, kategorie: string, menge: string, kommentar: string, ) {
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);
} }
} }

+ 2
- 1
src/app/app.module.ts View File

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: [
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
FormsModule,
ReactiveFormsModule ReactiveFormsModule
], ],
providers: [], providers: [],

+ 1
- 1
src/app/blog-entry.component.html View File

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

+ 3
- 1
src/app/blog-entry.ts View File

title: string; title: string;
image: string; image: string;
kategorie: string; kategorie: string;
text: string;
menge: string;
kommentar: string;

} }

+ 4
- 2
src/app/initialEntries.ts View File

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…
Cancel
Save