V0.1d Implementierung Einträge löschen (alle und letzten)
This commit is contained in:
parent
e8e0628f2d
commit
31bdc26861
@ -22,7 +22,13 @@
|
||||
</textarea>
|
||||
</div>
|
||||
<button (click)="createBlogEntry(title.value, image.value, kategorie.value,menge.value, kommentar.value)">
|
||||
Blog-Eintrag anlegen
|
||||
Eintrag anlegen
|
||||
</button>
|
||||
<button (click)="deleteAllEntries()">
|
||||
Alle Einträge löschen
|
||||
</button>
|
||||
<button (click)="deleteLastEntry()">
|
||||
Letzten Eintrag Löschen
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
@ -8,6 +8,11 @@ import {FormBuilder, Validators} from '@angular/forms';
|
||||
})
|
||||
export class AppComponent {
|
||||
|
||||
title = 'Einkaufszettel';
|
||||
entries: BlogEntry[] = [];
|
||||
isSubmitted = false;
|
||||
Kategorien: any = ['Lebensmittel', 'Spielwaren', 'Technik', 'Sonstiges'];
|
||||
|
||||
constructor(public fb: FormBuilder) {
|
||||
this.entries = [];
|
||||
this.entries = initialEntries;
|
||||
@ -17,11 +22,6 @@ export class AppComponent {
|
||||
get kategorieName() {
|
||||
return this.registrationForm.get('kategorieName');
|
||||
}
|
||||
title = 'Einkaufszettel';
|
||||
entries: BlogEntry[] = [];
|
||||
isSubmitted = false;
|
||||
// Kategorien
|
||||
Kategorien: any = ['Lebensmittel', 'Spielwaren', 'Technik', 'Sonstiges'];
|
||||
|
||||
/*########### Form ###########*/
|
||||
registrationForm = this.fb.group({
|
||||
@ -42,7 +42,20 @@ export class AppComponent {
|
||||
this.entries.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
deleteAllEntries() {
|
||||
console.log(this.entries.length);
|
||||
const index: number = this.entries.length;
|
||||
if (index !== -1) {
|
||||
this.entries = this.entries.splice(index, 1);
|
||||
}
|
||||
}
|
||||
deleteLastEntry() {
|
||||
console.log(this.entries.length);
|
||||
const index: number = this.entries.length;
|
||||
if (index !== -1) {
|
||||
this.entries.splice(index-1, 1);
|
||||
}
|
||||
}
|
||||
// Kategorie mit Drop Down Menu wählen
|
||||
changeKategorie(e) {
|
||||
console.log(e.value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user