AngularJS: Get selected Item
<p>I have an ng-repeat that display users in rows, when a user is clicked, it open modal popup for edit User containing all user details. When I select another role for the user and tries to get the newly selected row so as to pass to http put, it does not give the newly selected item text instead it still return the old text</p>

<p>//display users in table rows, click on username to edit</p>

<pre><code>    &lt;tr ng-repeat="item in usersData | filter: searchBox"&gt;

        &lt;td&gt;&lt;a ng-click="openEditUser($index)"&gt;{{item.UserName}}&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;{{item.EMail}}&lt;/td&gt;
        &lt;td&gt;{{item.RoleName}}&lt;/td&gt;
        &lt;td style="text-align: right;"&gt;{{item.IsActive ? 'Yes' : 'No'}}&lt;/td&gt;

 &lt;/tr&gt;
</code></pre>

<p>When the modal popup opens, I get all the roles from API and add it to <code>&lt;select&gt;</code> field</p>

<p>//get all roles and add to select field</p>

<pre><code>$http.get('mydomain.com/api/Users/GetAllRole').then(function (response) {
            $rootScope.myData = {};
            $rootScope.myData = response.data;
        });
</code></pre>

<p>// Here ng-model="selectedItem.RoleId"</p>

<pre><code>&lt;select ng-required="true" ng-model="selectedItem.RoleId" class="form-control"
                ng-options="item._id as item.RoleName for item in myData"&gt;
            &lt;option value=""&gt;Select&lt;/option&gt;                                


&lt;/select&gt;
</code></pre>

<p>Here when I choose another role for the user in the <code>&lt;select&gt;</code> field and try to get $scope.selectedItem.RoleId it gives the new selected RoleId but when I try to get $scope.selectedItem.RoleName from the <code>&lt;select&gt;</code> field it doesn't give the new selected item instead it still returns the old selected item</p>

<pre><code>$scope.EditUser = function(){

    $http.put("domain.com/api/Users/UpdateUser", {
       _id: $scope.selectedItem._id,'RoleId': $scope.selectedItem.RoleId, 'EMail': $scope.selectedItem.EMail, RoleName : $scope.selectedItem.RoleName, IsActive: $scope.selectedItem.IsActive

    }).then(function (response) {
        $route.reload();
        $scope.ok();
        $scope.simpleSuccess();
    }, function (error) {
        $scope.ok();
        $scope.simpleError();
    });


  };
</code></pre>