HTML
<template>
<template if:true={display}>
<lightning-card title="Student Information">
<div class="slds-n-around_medium">
<lightning-input label="First Name" value={name} onchange={firstNameHandler}></lightning-input>
<lightning-input label="Last Name" value={age} onchange={lastNameHandler}></lightning-input>
<lightning-input label="Grade" value={salary} onchange={gradeHandler}></lightning-input>
<lightning-input label="Roll Number" value={salary} onchange={rollNumberHandler}></lightning-input>
<lightning-button label="Save" onclick={saveButtonHandler}></lightning-button>
</div>
</lightning-card>
</template>
<template if:false={display}>
<lightning-card title="Student Information">
<div class="slds-m-around_medium">
<p>First Name: {firstName}</p>
<p>Last Name : {lastName}</p>
<p>Grade : {grade}</p>
<p>Roll Number : {rollNumber}</p>
</div>
</lightning-card>
</template>
</template>
JavaScript
import { LightningElement,track } from 'lwc';
export default class EmployeeInfo extends LightningElement {
@track firstName;
@track lastName;
@track grade;
@track rollNumber;
@track display=true;
firstNameHandler(event)
{
this.firstName=event.target.value;
}
lastNameHandler(event)
{
this.lastName=event.target.value;
}
gradeHandler(event)
{
this.grade=event.target.value;
}
rollNumberHandler(event)
{
this.rollNumber=event.target.value;
}
saveButtonHandler()
{
this.display=false;
}
}