I have a Parent ID/Child ID ng-repeat that where I am trying to display a message when it's child is empty. Cant quite get this to work correctly. Here is what I have:
(function() {
'use strict';
angular
.module('exampleApp', [])
.controller('ExampleController', ExampleController);
function ExampleController() {
var vm = this;
vm.Parent_data = [{
"id": "1234",
"ParentDetails": "Data and stuff here"
}, {
"id": "5423",
"ParentDetails": "Data and stuff here"
}, {
"id": "65342",
"ParentDetails": "Data and stuff here"
},{
"id": "7890",
"ParentDetails": "Data and stuff here"
}]
vm.Child_data = [{
"id": "1",
"listId": "1234",
"ChildDetails": "Data and stuff here"
}, {
"id": "2",
"listId": "5423",
"ChildDetails": "Data and stuff here"
}]
}
ExampleController.$inject = [];
})();
Here is the HTML markup example:
<!DOCTYPE html>
<html ng-app='exampleApp'>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script>
</head>
<body ng-controller="ExampleController as vm">
<table>
<tbody ng-repeat="parent in vm.Parent_data">
<tr>
<td> Parent details here: {{ parent.ParentDetails }} </td>
</tr>
<tr>
<td>
<table>
<tbody ng-repeat="child in vm.Child_data | filter:{ listId: parent.id }">
<tr>
<td>
<p >Details: {{child.ChildDetails}}</p>
</td>
</tr>
<tr ng-show="child.length === 0">
<td>
No data to show here ...
</td>
</tr>
<tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
For some reason, my " No data to show here ..." does not show up. I then tried this:
<tr ng-hide="child.length">
<td>
No data to show here ...
</td>
</tr>
Then the messge shows up everywhere even when its not suppose to. Anyone have any idea why this would be?
.lengthhiddenclass