Using AngularJS, I'm trying to only show items from a database once, link.DocCategory
and link.DocSubCategory
. Using | unique: 'DocCategory'
did not give me my expected result as it actually displays DocCategory
once but also removes other instances that share the same DocCategory
. I'd like to show the DocCategory
once with it's related DocSubCategory
items showing once with their related URL
info showing.
Here is my JSON structure:
{
"d": {
"results": [{
"URL": {
"Description": "Capabilities",
"Url": "https://www.test.com"
},
"Comments": null,
"DocCategory": "The LIFE Links",
"DocSubCategory": "The Sales Program",
"Order0": 1,
"Description": "<div class=\"ExternalClass7655A65DDC5041F9B50820BD16C94366\"><p>\u200bThis is a link to show all of the capabilities that we have to offer.</p></div>",
"Name": "Capabilities",
"ID": 1
}, {
"URL": {
"Description": "Abilities",
"Url": "https://www.test2.com"
},
"Comments": null,
"DocCategory": "The LIFE Links",
"DocSubCategory": "The Sales Program",
"Order0": 1,
"Description": "<div class=\"ExternalClass7655A65DDC5041F9B50820BD16C94366\"><p>\u200bThis is a link to show all of the abilities that we have to offer.</p></div>",
"Name": "Capabilities",
"ID": 1
}
]}
}
Here is my HTML:
<div ng-app="myApp">
<div ng-controller="MainCtrl">
<div class="container-fluid">
<div class="row">
<div class="col-md-6" ng-repeat= "link in links | unique:'DocCategory'">
<h1 class="category">{{link.DocCategory}}<h1>
<h2 class="subcategory"><span class="subcatspan">{{link.DocSubCategory}}</span></h2>
<a class="links" href={{link.URL.Url}} target="_blank">{{link.URL.Description}}</a>
</div>
</div>
</div>
</div>
</div>
Edit: I am trying to hide duplicate items in the view, not remove them altogether.