How to pass URL para value to AngularJS controller, edit these data, then store back to datastorage?

27 Views Asked by At

I listed input data from a form listed in HTML table using ng-repeat. I wanted to delete or update a row in the table. Please suggest how to pass the data value from a row to controller in AngularJS then how to write the edit function to change the data for this row then store back to data storage.

2

There are 2 best solutions below

1
P. Wle On

//Here is my delete function

    $scope.deleteUser = function (User) {  
        $scope.Users.splice($scope.Users.indexOf(User), 1);  
        getLocalStorage.updateUsers($scope.Users);  
        $scope.count = $scope.Users.length;  
    };  
1
P. Wle On
<!-- Here is my html part -->
<tr ng-repeat="User in Users">  
        <td>{{ $index + 1 }}  
            </td>  
            <td>{{ User.Userfname }}  
            </td>  
            <td>{{ User.Userlname }}  
            </td>  
            <td>{{ User.Userphone }}  
            </td> 
            <td class="pull-right"> 
            <a ng-click="editUser(User)" href="?index={{ $index 
}}&Userfname={{ User.Userfname }}&Userlname={{ User.Userlname }}&Userphone= 
{{ User.Userphone }}">Update</a>
                <button ng-click="deleteUser(User)">Delete</button>  
            </td>  
</tr>