diff --git a/src/app/add-edit-transaction/add-edit-transaction.component.html b/src/app/add-edit-transaction/add-edit-transaction.component.html
index 0f95f91..17d7261 100644
--- a/src/app/add-edit-transaction/add-edit-transaction.component.html
+++ b/src/app/add-edit-transaction/add-edit-transaction.component.html
@@ -26,10 +26,13 @@
-
+
+
+
+
+ {{ category.name }}
+
+
Expense
diff --git a/src/app/add-edit-transaction/add-edit-transaction.component.ts b/src/app/add-edit-transaction/add-edit-transaction.component.ts
index dd0002c..f430e1b 100644
--- a/src/app/add-edit-transaction/add-edit-transaction.component.ts
+++ b/src/app/add-edit-transaction/add-edit-transaction.component.ts
@@ -3,6 +3,8 @@ import { Transaction } from '../transaction'
import { TransactionType } from '../transaction.type'
import { TransactionService } from '../transaction.service'
import { Location } from '@angular/common';
+import { Category } from '../category'
+import { CategoryService } from '../category.service'
@Component({
selector: 'app-add-edit-transaction',
@@ -14,13 +16,16 @@ export class AddEditTransactionComponent implements OnInit {
@Input() title: string;
@Input() currentTransaction: Transaction;
public transactionType = TransactionType;
+ public selectedCategory: Category;
constructor(
+ private categoryService: CategoryService,
private transactionService: TransactionService,
private location: Location
) { }
ngOnInit() {
+ this.getCategories()
}
goBack(): void {
@@ -42,4 +47,8 @@ export class AddEditTransactionComponent implements OnInit {
this.transactionService.deleteTransaction(this.currentTransaction);
this.goBack()
}
+
+ getCategories() {
+ this.categoryService.getCategories().subscribe(categories => this.categories = categories)
+ }
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index abcaece..ba85515 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -11,6 +11,7 @@ import {
MatListModule,
MatRadioModule,
MatProgressBarModule,
+ MatSelectModule,
MatToolbarModule,
} from '@angular/material';
@@ -52,6 +53,7 @@ import { CategoryListComponent } from './category-list/category-list.component';
MatListModule,
MatRadioModule,
MatProgressBarModule,
+ MatSelectModule,
MatToolbarModule,
AppRoutingModule,
FormsModule
diff --git a/src/app/transaction.ts b/src/app/transaction.ts
index f2af498..fe4949a 100644
--- a/src/app/transaction.ts
+++ b/src/app/transaction.ts
@@ -1,5 +1,5 @@
import { ITransaction } from './budget-database'
-import { ICategory } from './budget-database'
+import { Category } from './category'
import { TransactionType } from './transaction.type';
export class Transaction implements ITransaction {
@@ -8,6 +8,6 @@ export class Transaction implements ITransaction {
description: string;
amount: number;
date: Date = new Date();
- category: ICategory;
+ categoryId: number;
type: TransactionType = TransactionType.EXPENSE;
}