web Form Elements Overview
MediDash provides a comprehensive set of form elements to help you build powerful and user-friendly forms. This guide will walk you through the process of creating a basic form, including the necessary dependencies, HTML structure, and component-side code.
extension Dependencies
To create a form, you need to import the following dependencies into your component file:
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
code HTML Structure
The following HTML code demonstrates how to create a basic form with email and password fields:
<form class="validate-form" [formGroup]="loginForm" (ngSubmit)="onSubmit()">
<div class="row">
<div class="col-lg-12">
<div class="form-group position-relative">
<label>Your Email <span class="text-danger">*</span></label>
<input type="email" class="form-control pl-5" formControlName="username" placeholder="Email">
</div>
</div>
<div class="col-lg-12">
<div class="form-group position-relative">
<label>Password <span class="text-danger">*</span></label>
<input type="password" class="form-control pl-5" formControlName="password" placeholder="Password">
</div>
</div>
</div>
</form>
developer_mode Component-Side Code
The following code demonstrates how to create the form group and validators in your component file:
loginForm: FormGroup;
ngOnInit() {
this.loginForm = this.formBuilder.group({
username: ['', Validators.required],
password: ['', Validators.required],
});
}
link Helpful Resources
For more information on creating and using forms in Angular, please refer to the official documentation:
| Topic | URL |
|---|---|
| Angular Forms | https://angular.io/guide/forms-overview |
Referral Url
| Type | URL |
|---|---|
| ng-bootstrap Form | https://ng-bootstrap.github.io/#/home |