user4756836
user4756836

Reputation: 1337

Take data from one list to another

I have two tables in my HTML. I want to take data from one list and pass it to another. I can't do the same ng-repeat call because on the second table I have one individual customer and I just want to display his ID. On the first table, I have all the customers.

<table border="1" id="userTable">
    <tr>
        <b>#</b>
    </tr>
    <tr ng-repeat="user in userList" ng-click="viewUserDiv()">
        <td ng-model="id">{{user.id}}</td>
    </tr>
</table>
<div ng-show="userDiv">
<table border="1">
    <tr>
        <b>#</b>
    </tr>
        <td ng-model="id">{{id}}</td>
</table>
</div>

Upvotes: 0

Views: 132

Answers (1)

Tj Gienger
Tj Gienger

Reputation: 1405

<table border="1" id="userTable">
    <tr>
        <b>#</b>
    </tr>
    <tr ng-repeat="user in userList" ng-click="viewUserDiv(user)">
        <td ng-model="id">{{user.id}}</td>
    </tr>
</table>


$scope.viewUserDiv = function(user) {
    if (user) {
        $scope.userDiv = true;
        $scope.userDivUser = user;
    }
}

<div ng-show="userDiv">
    <table border="1">
        <tr>
            <b>#</>
        </tr>
            <td ng-model="userDivUser">{{userDivUser.id}}</td>
    </table>
<div>

Upvotes: 1

Related Questions