I'm trying to display information grouped by address. For some reason orderBy and groupBy not working.
This is my view:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"> </script>
<div ng-app="app" ng-controller="ctrl">
<div ng-repeat="item in data | orderBy:'address' | groupBy:'address' " >
<h5 ng-click="toggle_visibility(item);">{{item.address}}</h5>
<div ng-hide="item.hideAddress">
<ul>
<li>First Name: {{item.firstname}} </li>
</ul>
</div>
</div>
</div>
This is my controller:
angular.module("app",[])
.controller("ctrl",function($scope){
$scope.data = [
{
firstname: "user",
address: "address1",
},
{
firstname: "user1",
address: "address1",
},
{
firstname: "user2",
address: "address3",
}
];
$scope.toggle_visibility = function(item){
item.hideAddress = !item.hideAddress;
}
})
When I add groupBy and run it, I get no data at all to display but if I remove groupBy I'll get the groups by address but 2 groups with the same address name. How can I fix it please?