Not able to insert data in few ReactJs Form input fields - reactjs

I am creating a form which has 23 input fields. In this form, i am not able to add any data through all fields are copy pasted.Few fields are editable I can enter any data while few fields are not editable I can see cursor but I cannot enter any data. Fields beneath long-term liablity are editable while above fields are not editable
<form onSubmit={this.handleSubmitFirebase}>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounting period</label>
<input type="date" className="form-control" ref={el => this.billto = el} onChange={this.handleChange} />
<input type="date" className="form-control" ref={el => this.billfrom = el} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">WORKING CAPITAL</label>
<input type="text" className="form-control" ref={el => this.state.capital = el} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">CURRENT ASSETS</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Cash</label>
<input type="text" className="form-control" value={this.state.cash} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Investments</label>
<input type="text" className="form-control" value={this.state.investments} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Inventories</label>
<input type="text" className="form-control" value={this.state.inventories} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounts receivable</label>
<input type="text" className="form-control" value={this.state.ac_receiv} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Pre-paid expenses</label>
<input type="text" className="form-control" value={this.state.pre_paid_exp} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Other</label>
<input type="text" className="form-control" value={this.state.other} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total current Assets</label>
<input type="text" className="form-control" value={this.state.curentAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">FiXED ASSETS</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Property and equipment</label>
<input type="text" className="form-control" value={this.state.prop_equipmnt} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Leasehold improvements</label>
<input type="text" className="form-control" value={this.state.leasehold} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Equity and other investments</label>
<input type="text" className="form-control" value={this.state.equity} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Less accumulated depreciation(-Value)</label>
<input type="text" className="form-control" value={this.state.accum_depreciation} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total fixed Assets</label>
<input type="text" className="form-control" value={this.state.fixedAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Other Assets</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Charity</label>
<input type="text" className="form-control" value={this.state.Charity} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total other Assets</label>
<input type="text" className="form-control" value={this.state.otherAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Grand Total Assets</label>
<input type="text" className="form-control" value={this.state.GrandotherAssetTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Current Liabilities</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounts payable</label>
<input type="text" className="form-control" value={this.state.acc_payable} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accrued wages</label>
<input type="text" className="form-control" value={this.state.accure_wages} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accrued compensation</label>
<input type="text" className="form-control" value={this.state.accure_compens} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accounts receivable</label>
<input type="text" className="form-control" value={this.state.acc_receivable} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Income taxes payable</label>
<input type="text" className="form-control" value={this.state.it_tax_payble} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Unearned revenue</label>
<input type="text" className="form-control" value={this.state.uneared_revenue} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Other</label>
<input type="text" className="form-control" value={this.state.OtherLiability} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total current Liabilities</label>
<input type="text" className="form-control" value={this.state.currLiabilitiesTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Long-term Liabilities</label>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Mortgage payable</label>
<input type="text" className="form-control" value={this.state.mortg_payable} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total Long-termLiabilities</label>
<input type="text" className="form-control" value={this.state.longtermLiabilitiesTotal} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Owner Equity</label>
<input type="text" className="form-control" value={this.state.owner_equity} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Investment capital</label>
<input type="text" className="form-control" value={this.state.investment_capital} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Accumulated retained earnings</label>
<input type="text" className="form-control" value={this.state.accuml_earning} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total</label>
<input type="text" className="form-control" value={this.state.totalOwnerEquity} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<label className="control-label">Total Liabilities & Stockholder Equity</label>
<input type="text" className="form-control" value={this.state.totalLaibility_stackEquity} onClick={this.countTotal} onChange={this.handleChange} />
<span className="material-input"></span>
</div>
<div className="form-group label-floating is-empty">
<span className="material-input"></span>
</div>
<button type="submit" className="btn btn-fill btn-rose">Submit</button>
</form>

I can't be sure without the rest of the code, but it sounds like you are using Controlled Components without updating their values with the onChange callback.
When you set the value attribute it gets "binded" to the variable you set it to. For example, <input type="text" className="form-control" value={this.state.inventories} onChange={this.handleChange} />, the value of this input will be the value of this.state.inventories. If you don't update the latter you can't change the input value. To update this value you use the onChange callback, which is set as this.handleChange, but I'm not sure you wrote the method.
On the this.handleChange method you'll use setState to change the this.state.inventories value to the value being written in the form, something like this:
handleChange(event) {
this.setState({inventories: event.target.value});
}
EDIT:
Another thing to be noted: All the inputs are using the same callback to update their values, so you can't just add this.setState({state: event.target.value}); for each one, because event.target.value will be set to the value of the input being edited when the callback is fired. You need a conditional to check which input is being edited.
One of the ways to do it is to add a name to the input and check it through event.target.name in the onChange callback. As I advised in the comment, you should read the ReactJS documentation on forms.

Related

How to add Image field on right side in bootstrap form

I have an bootstrap form with 9 input field.I have applied 3 field in each row which looks as responsive.I would like to know how to add image field on right side and which should be span of three row.please check my below code and advise how to align the image control as right side.
updated code version 3.0.0:-
<div className="container-fluid">
<div className="row">
<div className="col-sm-10">
<div className="container-fluid">
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3 pl-0">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName"
placeholder="First Name" value={ this.state.FirstName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3 pl-0">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName"
placeholder="Last Name" value={ this.state.LastName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3 pl-0">
<input type="email" name="EmailId" className="form-control form-control-sm" id="TxtEmailId"
placeholder="EmailId" value={ this.state.EmailId } required onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3 pl-0">
<input type="text" name="MobileNo" className="form-control form-control-sm" id="TxtMobileNo"
placeholder="Mobile No" value={ this.state.MobileNo } onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3 pl-0">
<select name="DivisionId" className="form-control" required value={ this.state.DivisionId }
onChange={ this.onChangeHandler }>
{ DivisionList }
</select>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">User Name</label>
<div className="col-sm-3 pl-0">
<input type="text" name="UserName" className="form-control form-control-sm" id="TxtUserName"
placeholder="User Name" value={ this.state.UserName } required
onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Password</label>
<div className="col-sm-3 pl-0">
<input type="password" name="DPassword" className="form-control form-control-sm" id="TxtPassword"
placeholder="Password" value={ this.state.DPassword } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Confirm</label>
<div className="col-sm-3 pl-0">
<input type="password" name="ConfirmPassword" className="form-control form-control-sm"
id="TxtConfirm" placeholder="Confirm Password" required value={ this.state.ConfirmPassword }
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Role</label>
<div className="col-sm-3 pl-0">
<select name="RoleId" data-show-subtext="true" data-live-search="true"
className="form-control selectpicker" id="CboRole" value={ this.state.RoleId } required
onChange={ this.onChangeHandler }>
{ RoleList }
</select>
</div>
</div>
</div>
</div>
<div className="col-sm-2">
<img className='img-fluid' src={ users } alt='Alt text'/>
</div>
</div>
</div>
screenshot :-
It depends on how many cols do you want your image to take, but what you can do is the following: Wrap your code in a new Row. Then divide it into as many columns as you want (for the example I have divided it 50:50 - 50% of the screen will be filled with your inputs and 50% with the image) - you can configure this by yourself. Try the following and let me know if this is what you seek:
<div className="container-fluid">
<div className="row">
<div className="col-sm-6">
<div className="container-fluid">
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName"
placeholder="First Name" value={ this.state.FirstName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName"
placeholder="Last Name" value={ this.state.LastName } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3">
<input type="email" name="EmailId" className="form-control form-control-sm" id="TxtEmailId"
placeholder="EmailId" value={ this.state.EmailId } required onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3">
<input type="text" name="MobileNo" className="form-control form-control-sm" id="TxtMobileNo"
placeholder="Mobile No" value={ this.state.MobileNo } onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3">
<select name="DivisionId" className="form-control" required value={ this.state.DivisionId }
onChange={ this.onChangeHandler }>
{ DivisionList }
</select>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">User Name</label>
<div className="col-sm-3">
<input type="text" name="UserName" className="form-control form-control-sm" id="TxtUserName"
placeholder="User Name" value={ this.state.UserName } required
onChange={ this.onChangeHandler }/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Password</label>
<div className="col-sm-3">
<input type="password" name="DPassword" className="form-control form-control-sm" id="TxtPassword"
placeholder="Password" value={ this.state.DPassword } required
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Confirm</label>
<div className="col-sm-3">
<input type="password" name="ConfirmPassword" className="form-control form-control-sm"
id="TxtConfirm" placeholder="Confirm Password" required value={ this.state.ConfirmPassword }
onChange={ this.onChangeHandler }/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Role</label>
<div className="col-sm-3">
<select name="RoleId" data-show-subtext="true" data-live-search="true"
className="form-control selectpicker" id="CboRole" value={ this.state.RoleId } required
onChange={ this.onChangeHandler }>
{ RoleList }
</select>
</div>
</div>
</div>
</div>
<div className="col-sm-6">
<img className='img-fluid' src={ path } alt='Alt text'/>
</div>
</div>
</div>

How to enable/ disable react form based on condition

I have an react js form.I would like to know how to enable/disable all form input control based on condition.please check my below code and advise how to do this...
return (
<form id ="frm" onSubmit={this.onSubmitHandler}>
<div className="animated fadeIn">
<div className="form-group row">
<Button type="button" text="Back" size="sm" onClick={this.onBackButtonClick} color="danger" className="pull-right ml-1 "><i className="fa fa-ban"></i> Back</Button>
<Button type="submit" size="sm" color="success" className="pull-right ml-1 "><i className="fa fa-dot-circle-o"></i> Save</Button>
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName" placeholder="First Name" value={this.state.FirstName} required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Last Name</label>
<div className="col-sm-3">
<input type="text" name="LastName" className="form-control form-control-sm" id="TxtLastName" placeholder="Last Name" value={this.state.LastName} required onChange={this.onChangeHandler}/>
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Email Id</label>
<div className="col-sm-3">
<input type="email" name ="EmailId" className="form-control form-control-sm" id="TxtEmailId" placeholder="EmailId" value={this.state.EmailId} required onChange={this.onChangeHandler}/>
</div>
</div>
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">Mobile No</label>
<div className="col-sm-3">
<input type="text" name ="MobileNo" className="form-control form-control-sm" id="TxtMobileNo" placeholder="Mobile No" value={this.state.MobileNo} onChange={this.onChangeHandler} />
</div>
<label className="col-sm-1 col-form-label col-form-label-sm">Division</label>
<div className="col-sm-3">
<select name ="DivisionId" className="form-control" required value={this.state.DivisionId} onChange={this.onChangeHandler}>
{DivisionList}
</select>
</div>
/div>
</form>
);
ComponentDidMount Event to check condition :-
componentDidMount() {
if (this.props.match.params.mode=="Edit"){
// enable form control
}
else
{
// disable form control
}
create a state isFormDisabled for ex.
use html fieldset inside the form and use disabled property and provide the value of isFormDisabled
use your logic to enable/disable based on your needs
Code Sample
...
state = {
isFormDisabled: false
}
componentDidMount(){
if (this.props.match.params.mode == "Edit") {
this.setState({isFormDisabled: false})
}
else {
this.setState({isFormDisabled: true})
}
}
...
//inside render fun...
return (
<form id ="frm" onSubmit={this.onSubmitHandler}>
<fieldset disabled={isFormDisabled}>
<div className="animated fadeIn">
<div className="form-group row">
<label className="col-sm-1 col-form-label col-form-label-sm">First Name</label>
<div className="col-sm-3">
<input type="text" name="FirstName" className="form-control form-control-sm" id="TxtFirstName" placeholder="First Name" value={this.state.FirstName} required onChange={this.onChangeHandler}/>
</div>
...
</fieldset>
...

tabindex is not working with required attribute

<div class="row">
<div class="col-md-6">
<div class="form-body">
<div class="form-group">
<label>First Name</label>
<div class="input-group">
<input type="text" tabIndex="1" name="first_name" class="form-control">
</div>
</div>
<div class="form-group">
<label>Email Address</label>
<div class="input-group">
<input type="email" tabIndex="3" name="username" class="form-control" ng-model="username" required user-exist /><br/> <span style="color: red" ng-show="partnerForm.username.$touched && partnerForm.username.$invalid">
<span ng-show="partnerForm.username.$error.required">Email is required.</span>
<span ng-show="partnerForm.username.$error.email">Enter Correct Format.</span>
<span ng-show="partnerForm.username.$error.userExist">User already exists.</span>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-body">
<div class="form-group">
<label>Last Name</label>
<div class="input-group">
<input type="text" tabIndex="2" name="last_name" class="form-control">
</div>
</div>
</div>
</div>
</div>
the tabindex 3 is not working.i have checked by removing the required attr then it is working .the attributes required and tabindex is conflicting with each other.please help me to solve this.or provide a directive (working) for tabindex.

Custom Form Validation Not working in angularjs

I want to validate all the fields in this form by angular, but it is not working. I am new to angular and cant find what the problem is. None of the field in this form is being validated
<form class="form-horizontal" role="form" name="commentForm" ng-submit="submitComment()" novalidate>
<div class="form-group" ng-class="{'has-error': commentForm.name.$error.required && !commentForm.name.$pristine}">
<label for="name" class="col-xs-2">Your Name</label>
<div class="col-xs-10">
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Your Name" ng-model="dishComment.author">
<span class="help-block" ng-show="commentForm.name.$error.required && !commentForm.name.$pristine">Your Name is Required</span>
</div>
</div>
<div class="form-group">
<label for="rating" class="col-xs-2">Number of Stars</label>
<div class="col-xs-10">
<label class="radio-inline">
<input type="radio" name="rating" id="rating" value="1" ng-model="dishComment.rating"> 1
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="rating" value="2" ng-model="dishComment.rating"> 2
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="rating" value="3" ng-model="dishComment.rating"> 3
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="rating" value="4" ng-model="dishComment.rating"> 4
</label>
<label class="radio-inline">
<input type="radio" name="rating" id="rating" value="5" ng-model="dishComment.rating"> 5
</label>
</div>
</div>
<div class="form-group" class="{'has-error': commentForm.comments.$error.required && !commentForm.comments.$pristine}">
<label for="comments" class="col-xs-2">Your comments</label>
<div class="col-xs-10">
<textarea class="form-control" id="comments" name="comments" rows="12" ng-model="dishComment.comment"></textarea>
<span class="help-block" ng-show="commentForm.comments.$error.required && !commentForm.comments.$pristine">Please Write a comment</span>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-disabled="commentForm.$invalid">Submit Comment</button>
</div>
</div>
</form>
I think you only missed required in input element.
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Your Name" ng-model="dishComment.author" required>
I just added required for one input element and its working.
Please check jsfiddle
I am using input fields, something like below structure. as Nitish said, you must need to write required in input element.
AppForm is a form name.
<md-input-container flex="50" flex-gt-xs="33" md-is-error="AppForm.txtApplicationUrl.$invalid && (AppForm.$submitted || AppForm.txtApplicationUrl.$dirty)">
<label for="input_0">Your label</label>
<input type="text" ng-model="applicationDetails.Applicationurl" name="txtApplicationUrl" tabindex="0" id="txtApplicationUrl" aria-invalid="false" required><div class="md-errors-spacer"></div>
<div ng-messages="AppForm.txtApplicationUrl.$error" ng-if="AppForm.$submitted || AppForm.txtApplicationUrl.$touched">
<div ng-message="required">Custom Message</div>
</div>
</md-input-container>

Form Closing Tag Not Showing In Console

its very strange that i am closing the form input field tags but even though i didn’t find it in console.even my form value didn't getting posted.
here is my code
<form ng-submit="updatepersonel()" ng-repeat="update in userDetail">
<div class="form-group">
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.firstname" />
<label for="exampleInputPassword1">First Name</label>
<div class="form-group">
<label for="exampleInputPassword1">Last Name</label>
<input type="text" class="form-control" ng-model="perupdate.lastname" ng-value="update.lastname" />
</div>
<div class="form-group" />
<label for="exampleInputPassword1">Phone</label>
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.phone" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Location</label>
<input type="text" class="form-control full" ng-model="perupdate.location" ng-value="update.location" />
</div>
<button class="btn btn-success" type="submit">Update</button>
</form>
Edited::
<div class="form-group">
<form ng-submit="updatepersonel()" ng-repeat="update in userDetail">
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.firstname" />
<label for="exampleInputPassword1">First Name</label>
<div class="form-group">
<label for="exampleInputPassword1">Last Name</label>
<input type="text" class="form-control" ng-model="perupdate.lastname" ng-value="update.lastname" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Phone</label>
<input type="text" class="form-control full" ng-model="perupdate.firstname" ng-value="update.phone" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Location</label>
<input type="text" class="form-control full" ng-model="perupdate.location" ng-value="update.location" />
</div>
<button class="btn btn-success" type="submit">Update</button>
</form>
</div>
i have solved my issue.
what i was doing i was trying to get the data in ng-value.
But when i try to bind data in my ng-model i get the solution
js
$scope.perupdate= {
firstname: key.firstname,
lastname : key.lastname,
phone : key.phone,
location : key.location,
};
view
<input type="text" class="form-control full" ng-model="perupdate.firstname">

Resources