Basic Form
For create form you have to include following dependency in your component file.
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
HTML code for basic form
<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>
component ts file have following code
loginForm: FormGroup;
ngOnInit() {
this.loginForm = this.formBuilder.group({
username: ['', Validators.required],
password: ['', Validators.required],
});
}
Referral Url
Type | URL |
---|---|
ng-bootstrap Form | https://ng-bootstrap.github.io/#/home |