PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Angular · Theory

Events

← All stacks

Theory

10/43

Events

Events: (click), (input), (submit), (keyup.enter). The handler lives on the class. $event is the browser event when you need the value.

Board: <form (ngSubmit)="save($event)">. Call $event.preventDefault() or use ngSubmit so the page doesn’t reload. Trap: (click) on a submit button without preventDefault.

Exam tip

(click) vs ngSubmit. preventDefault.

Example

import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  template: `
    <h1>{{ title }}</h1>
    <button (click)="toggle()">Toggle</button>
    <p *ngIf="open">Panel open</p>
  `,
})
export class AppComponent {
  title = "Angular practice";
  open = true;
  toggle() {
    this.open = !this.open;
  }
}

Events: toggle open. Say whether the panel is on screen after one click.

Short notes

  • Def(event)="handler()". Logic in the class.
  • RuleForms use ngSubmit, not only click.
  • TrapFull page reload on submit.

Questions

1

How do you handle a click in Angular?

Previous← Data BindingNextConditional →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.