So, I tried to create a good way to represent hierarchical data in my application. I created a slide effect for some boot icons, which I use to display some subcategories using AngularJS.
I created (with some help from you stackoverflow-ers!) The following example that works for data like parent and child. i.e. You cannot be a parent and a child at the same time, which is necessary for my real example.
<ul> <li ng-repeat="category in categories" ng-init="isChild = category.category_type == 'child'" ng-show="category.category_show" class="badge-slider"> <span class="badge {{ isChild ? 'badge-c' : 'badge-p' }}" ng-click="isChild || updateResults(category)" ng-bind="category.category_name"> </span> </li> </ul>
I am trying to figure out what is the best way to change the code so that it can work for the optional parent and child types of category_type. This type of "parent and child" category_type is needed to create a way to view the directory structure.
In the above example, it relies on the boolean value of isChild and the ternary operator, which does not work when we introduce the category "parent and child" category_type.
Does anyone have any ideas?
Here is a link to PLNKR that demonstrates rolling functionality that works for simple parent-child relationships: http://plnkr.co/edit/9CiXW1YAoPj80x6PtBW3
EDIT 1:
I created another PLNKR to handle the three-level nature of hierarchical relationships. It works great, except that it does not display the parent and child elements with the corresponding icon .... http://plnkr.co/edit/YoRI578GHE91t6torCUt
source share