0

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.

0

1 Answer 1

1

Change ng-model="Fname" to ng-model="FNAME".

Probably, this will do the binding.

Sign up to request clarification or add additional context in comments.

2 Comments

I wrote $scope.Fname = usr.FNAME and This is worked. Thanks for the trick.
All the best @NiranjanGodbole

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.