Hi I am developing one application in AngularJS with MVC5. I am trying to get Data based on ID from database. My server side code is working correctly. I am finding difficulties in binding data to controls in angularJS controller. I am new to the world of AngularJS. This is what I am trying so far.
<tr ng-repeat="usr in userList">
<td>
{{usr.ID}}
</td>
<td>
{{usr.FNAME}}
</td>
<td>
{{usr.LNAME}}
</td>
<td>
{{usr.USERNAME}}
</td>
<td>
{{usr.JOINING_DATE}}
</td>
<td>
<input type="button" value="Edit User" span ng-click="editUser(usr)"/>
<span ng-click="editUser(usr)" class="btnRed">Delete</span>
</td>
</tr>
This is my service.js code.
this.getUser = function (ID) {
var response = $http({
method: "post",
url: "CreateUser/getUserByNo",
params: {
id: JSON.stringify(ID)
}
});
return response;
}
This is my angularJS controller code.
$scope.editUser = function (usr) {
debugger;
var getData = CreateUserService.getUser(usr.ID);
getData.then(function (emp) {
$scope.usr = emp.data;
$scope.FNAME = usr.FNAME;
$scope.Lname = usr.Lname;
$scope.UserName = usr.UserName;
$scope.JoiningDate = usr.JoiningDate;
},
function () {
alert('Error in getting records');
});
}
I am trying to bind data to the below textboxes.
<input type="text" id="Fname" class="Fname" ng-model="Fname" />
In angularJS controller my data is not binding using below code. $scope.FNAME = usr.FNAME; May I get some idea where I am doing things wrong? Thank you very much.