Welcome to BudgetManager, an Angular application designed to efficiently manage and calculate budgets. This project follows best practices in business logic separation, reactive forms, and dynamic filtering & sorting for a seamless user experience.
- Dynamic URLs: Uses route parameters to display budget details dynamically.
- Business Logic in Services: Implements service-based architecture for cleaner and maintainable code.
- Reactive Forms: Uses Angular's
FormGroup
andFormControl
for dynamic, real-time form validation and management. - Filtering & Sorting: Allows users to filter budget entries and sort results based on different criteria.
- State Management: Ensures reactive and efficient handling of budget data.
git clone https://github.com/adptCode/presupuestos.git
cd presupuestos
npm install
ng serve -o
This will automatically open the application in your default browser at http://localhost:4200/
. The application supports hot-reloading, so any changes you make to the source files will reflect in real-time.
The application utilizes Angular's ActivatedRoute to dynamically display budget details based on the URL.
Example:
this.route.paramMap.subscribe(params => {
const id = params.get('id');
this.loadBudgetDetails(id);
});
Routes Configuration:
const routes: Routes = [
{ path: 'budget/:id', component: BudgetDetailComponent }
];
The application follows best practices by handling budget calculations and data processing inside Angular services, keeping components lean and focused on presentation.
Example of a budget service:
@Injectable({ providedIn: 'root' })
export class BudgetService {
private budgets: Budget[] = [];
getBudgets(): Budget[] {
return [...this.budgets];
}
addBudget(budget: Budget): void {
this.budgets.push(budget);
}
}
Instead of template-driven forms, this project leverages Reactive Forms for better control and dynamic validation.
Example:
this.budgetForm = this.fb.group({
name: ['', Validators.required],
amount: [0, [Validators.required, Validators.min(1)]]
});
Users can filter budget items based on predefined criteria and sort results dynamically.
Example:
filterBudgets(criteria: string): Budget[] {
return this.budgets.filter(budget => budget.category.includes(criteria));
}
sortBudgets(order: 'asc' | 'desc'): Budget[] {
return this.budgets.sort((a, b) => order === 'asc' ? a.amount - b.amount : b.amount - a.amount);
}
In the project directory, you can run the following scripts:
ng serve
: Compiles and serves the application, rebuilding on file changes.ng build
: Compiles the application into an output directory.ng test
: Executes unit tests via Karma.ng lint
: Runs linting tools to analyze code quality.
For a complete list of available scripts and their descriptions, refer to the package.json
file.
Contributions are welcome! If you have suggestions for improvements or encounter any issues, feel free to open an issue or submit a pull request. Please ensure that your contributions align with the project's coding standards and conventions.
This project is licensed under the MIT License. See the LICENSE file for more information.
🚀 Happy coding!