A lightweight frontend for PollSystem built with Angular (standalone components) and Tailwind-style utility classes.
This README covers project overview, setup, common commands, structure, known issues found while exploring the codebase, and recommended fixes.
This repository contains the frontend for PollSystem. It includes authentication UI (login, registration) and several "Polls" section such as "My Polls", "Voted Polls" and "All Polls". The project uses Angular standalone components and reactive forms.
- Angular (standalone components)
- TypeScript
- Tailwind utilities (used via CDN in templates)
- Angular Material (some modules imported)
- HTTP client for auth API calls
- Node.js >= 16 (recommended 18+)
- npm (or yarn / pnpm)
- Optional: Angular CLI for developer convenience
On macOS you can install Node via Homebrew:
brew install nodeOpen Terminal, then:
- Clone repo (if not already):
git clone <your-repo-url>
cd PollSystem/fe/poll-system-fe- Install dependencies:
npm install
# or
# yarn
# pnpm installIf you have the Angular CLI installed:
ng serve --openIf you don't have the global CLI, use npx:
npx ng serve --openAlternative (if package.json has scripts):
npm start
# or
npm run startng build
# or
npx ng build
# or
npm run buildThe built files output will be in dist/ by default.
- src/app/auth/login/login.component.ts — login component (ReactiveForms)
- src/app/auth/login/login.component.html — login template
- src/app/auth/registration/registration.component.ts — registration component (ReactiveForms)
- src/app/auth/registration/registration.component.html — registration template
- src/app/auth/auth.service.ts — auth HTTP calls (not shown fully in attachments)
- src/app/... — other components and shared DTOs
- Registration form values empty at submit
- Symptom:
this.registerForm.get('email')!.valuereturns empty string even after typing. - Likely cause: component template contains a full HTML document (
<html>,<head>,<body>) rather than the component's inner HTML. Angular expects component templates to be fragments, not full documents. When a template includes these tags the Angular bindings may not attach to the rendered inputs. - Fix: Edit
registration.component.htmland remove the outer<html>,<head>, and<body>tags. Keep only the inner markup (container, form, inputs). Example:<!-- keep only inner HTML --> <div class="main-container"> <!-- form markup here --> </div>
- Password visibility toggle not working (clicking eye doesn't show password)
- Symptom: clicking the eye keeps the password masked.
- Causes found in the codebase:
- Button inside a form without
type="button"may cause submit behavior. - Script accessing DOM elements may run before the DOM exists (timing).
- Using direct DOM manipulation is fragile in Angular.
- Button inside a form without
- Fixes:
- Ensure the toggle button has
type="button"(so it doesn't submit the form). - Prefer Angular approach: bind
(click)="togglePasswordVisibility()"and implement toggling using template references or component variables. Example (recommended):And in component:<input #pwdInput [type]="passwordVisible ? 'text' : 'password'" formControlName="password" /> <button type="button" (click)="passwordVisible = !passwordVisible">...</button>
passwordVisible = false;
- If keeping DOM methods, call them from
ngAfterViewInitor ensure handlers callevent.preventDefault()and toggle icons safely.
- Ensure the toggle button has
- Router.navigate error: "Property 'navigate' does not exist on type 'Router'"
- Likely cause: incorrect import/name clash. Make sure you import Router from Angular:
And inject via constructor:
import { Router } from '@angular/router';
constructor(private router: Router) {}
- Tailwind via CDN in component templates
- The templates include
<script src="https://cdn.tailwindcss.com"></script>— this works for quick prototyping but isn't ideal for production builds. Consider integrating Tailwind with the Angular build pipeline (postcss) so utilities are available globally via styles and purged in production.
- Fork, create a feature branch, submit PR with descriptive message.
- Keep changes focused and include tests where feasible.