I have an angular smart-table of customers what I want is:
=> When I select one customer, I display another table with contacts of the customer that I had selected.
So how to pass the id of the customer to the second table?
Thank you in advance
Update:
<div class="table-responsive">
<table st-table="displayedCollection" st-safe-src="ref" class="table table-striped">
<thead>
<tr>
<th>id</th>
<th>rDescription</th>
<th>rLanguage</th>
<th>lastVersion</th>
<th>linkSet</th>
<th>Actions</th>
</tr>
<th colspan="5">
<input st-search="{{selectedPredicate}}" placeholder="bound predicate" class="input-sm form-control" type="search"/>
</th>
</thead>
<tbody>
<tr ng-repeat="row in displayedCollection" data-ng-click="select(row)">
<td>{{row._id}}</td>
<td>{{row.rDescription}}</td>
<td>{{row.rLanguage}}</td>
<td>{{row.lastVersion}}</td>
<td>{{row.linkSet}}</td>
<td class="text-center">
<div class="btn-group">
<button class="Details" ng-click="Details(row);">Details</button>
</div>
</td>
</tr>
</tbody>
</table>
and this is my controller where I just get my id (for test):
app.controller("listctrl",["$scope","Restangular",function($scope,Restangular){
$scope.ref = Restangular.all("referential").getList().$object;
$scope.predicates = ['rDescription', 'rLanguage', 'lastVersion', 'linkSet'];
$scope.selectedPredicate = $scope.predicates[0];
$scope.SaveData = function(row) {
alert("coucou " + row._id);
};
}]);
what I need to do now is to share id between my two controllers is this the right way ?
app.controller("listctrl",["$scope","Restangular",function($scope,Restangular){
$scope.ref = Restangular.all("referential").getList().$object;
$scope.predicates = ['rDescription', 'rLanguage', 'lastVersion', 'linkSet'];
$scope.selectedPredicate = $scope.predicates[0];
$scope.SaveData = function(row) {
return row._id;
};
}]);
app.controller("listdetailctrl", function ($scope , SaveData) {
$scope.refe = Restangular.one("referential",SaveData).getList();
});
Also I'm asking if there is a better way to do this: (the second table is hidden until we click on button
do pass you customer id by click event in angular by ng-click and by passing object containing id for particular index no. eg.
<tr ng-repeat="x in customer">
<td>{{x.id}} <input type="button" ng-click="getDetails(x.id)"></td>
<td>{{ x.Name }}</td>
<td>{{ x.Country }}</td>