I have a textbox which display the code of users
<label class="control-label">USER CODE:</label>
<input placeholder="Enter a User Code" type="text" class="form-control" ng-model="user.userCode"/>
On a show button it calls an api which fetches the product code assigned to particular user.
<button type="button" class="btn btn-info"><i class="fa fa-hand-o-up" ng-click="getAssignedProducts(user.userCode)"></i>Show</button>
The product code is displayed in the table:-
<label style="text-align:center;">Mapped Products:</label>
<table cellpadding="0" cellspacing="0" style="margin:auto;">
<thead>
<tr>
<th>Product Code</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in assignedProduct track by $index">
<td></td>
</tr>
</tbody>
</table>
My api code is:-
function getAssignedProducts(userCode) {
return $http({
method: 'GET',
url: '/api/user/assignedProduct?userCode=' + userCode
});
}
My directive code:-
scope.getAssignedProduct = function (userCode) {
ApiServices.getAssignedProduct(userCode).then(
function (response) {
scope.assignedProduct=response.data;
},
function (err) {
// Handle error here
console.log('Error' + JSON.stringify(err.data));
});
}
Here, assignedProduct is an array in backend which stores string values.
What my issue is, the api is calling correctly but the data is not displaying in table.I think I am not displaying data correctly in directive. Can anyone tell me where is my mistake.
via shreya gupta
No comments:
Post a Comment