I am new to AngularJS. I have a problem with ng-model
.
In one of my pages I have a list view. Each list can be deleted or it can be edited. What I need is when I click the edit button, I have to pass the particular list values to another controller and it should be shown in a separate textfields. In this new controller I have an update button, so that if any changes in the textfield can be sent to server. Problem is ng-model
is not working as I am showing the list values as value="{{list.name}}"
. Below is my full code.
From my first controller I am passing values to next by this method:
$scope.edit = function(item) {
$state.go('app.editemployer',{emp : item.emp_id,empname: item.emp_name,empcontact: item.emp_contact,companyname: item.comp_name,mobile: item.mobile,address: item.address1,addre: item.address2,city: item.city,states: item.state,postcode: item.zipcode,username: item.username,pass: item.password,email: item.emailid});
};
Then in my app.js as follows:
.state('app.editemployer', {
url: "/editemployer/:emp/:empname/:empcontact/:companyname/:mobile/:address/:addre/:city/:states/:postcode/:username/:pass/:email",
views: {
'menuContent': {
templateUrl: "templates/editemployer.html",
controller: 'editemployersCtrl'
}
}
})
Then in editemployer.html page I am showing the values in textfield like below:
<form class="form-horizontal" >
<div class="form-group" >
<label for="inputEmail" class="control-label col-xs-6">
EMPLOYER NAME</label>
<div class="col-xs-6">
<p class="form-control-static"><input type="text" value="{{name}}" ng-model="data.name"></p>
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="control-label col-xs-6">EMPLOYER CONTACT</label>
<div class="col-xs-6">
<p class="form-control-static"><input type="text" value="{{contact}}" ng-model="data.contact"></p>
</div>
</div>
</form>
Then in editemployersCtrl
controller.js as follows:
.controller('editemployersCtrl',function($scope,$http,$ionicLoading,$state)
{
$scope.emp=$state.params.emp;
$scope.name =$state.params.empname;
$scope.contact =$state.params.empcontact;
$scope.cmpname =$state.params.companyname;
}
What I am getting after selecting edit button is, wherever I used ng-model
, those textfields values are becoming empty and not showing inside it. I need it to show in the textfield, edit it and pass to server.