I want to add date/calendar in my angular7 form but I do not know how. Please help. I'm new and trying to learn by creating a simple angular7 form with .net web api and microsoft sql server.
- User.component.html file
<html>
<form #form="ngForm" (submit)="onSubmit(form)">
<div class="form-group">
<label> USERNAME</label>
<input name="UserName" #UserName="ngModel" [(ngModel)]="UserService.formData.UserName" class="form-control">
</div>
<div class="form-group">
<label> FULLNAME</label>
<input name="FullName" #FullName="ngModel" [(ngModel)]="UserService.formData.FullName" class="form-control">
</div>
<div class="form-group">
<label> MULTIPLE ROLES</label>
<input name="MultipleRoles" #MultipleRoles="ngModel" [(ngModel)]="UserService.formData.MultiplesRoles" class="form-
control">
</div>
<div class="form-group">
<label> STATUS</label>
<input name="Status" #Status="ngModel" [(ngModel)]="UserService.formData.Status" class="form-control">
</div>
<div class="form-group">
<label> Create Date</label>
</div>
<div class="form-group">
<label> Create By </label>
<input name="CreateBy" #CreateBy="ngModel" [(ngModel)]="UserService.formData.CreateBy" class="form-control">
</div>
<div class="form-group">
<input type="button" value="SUBMIT" class="btn btn-lg btn-block">
</div>
</form>
</html>
User.cs
namespace UserManagement3.Models { using System; using System.Collections.Generic;
public partial class User { public int Id { get; set; } public string UserName { get; set; } public string FullName { get; set; } public string MultipleRoles { get; set; } public string Status { get; set; } public Nullable<System.DateTime> CreateDate { get; set; } public string CreateBy { get; set; }}}User.model.ts
export class User { Id: number; UserName: string; FullName: string; MultipleRoles: string; Status: string; CreateDate: string; CreateBy: string;}user.component.ts
resetForm(form?: NgForm) {
if (form != null) {
form.resetForm();
this.UserService.formData = {
Id : null,
UserName: '',
FullName: '',
MultipleRoles: '',
Status: '',
CreateDate: '',
CreateBy: '',
};
}
}
I want to add datepicker/calendar in the CreateDate form. and pass the form in db in mssm.