I have the first group 3 buttons: line, spline and bar.
The second group: single, double and triple.
What I want to do it to make the second group buttons to be enabled or disabled depending on which one from the first group is clicked like this:
- if
lineis clicked all three (single,doubleandtriple) are enabled - if
splineofbaris clicked onlysingleis enabled,doubleandtripleare disabled.
This is the array of objects I'm using (probably it could be a better way to organize it):
myList = [
{ name: 'Line', icon:'line', subList: [{ name : 'Single', icon:'a' },
{ name : 'Double', icon: 'b' },
{ name : 'Triple', icon: 'c' }]},
{ name : 'Spline', icon: 'spline', subList: [{ name: 'Single', icon:'a' }]},
{ name : 'Bar', icon: 'bar', subList: [{ name: 'Single', icon:'c' }] }
];
Here I generate the first group of buttons:
<div class="btn-group btn-group-sm">
<i ng-repeat="view in $ctrl.myList"
ng-class="$ctrl.isViewSet(view) ? 'btn-primary' : 'btn-default'"
ng-click="!$ctrl.disableViews && $ctrl.setView(view)"
ng-disabled="$ctrl.disableViews">
</i>
</div>
This is the second one:
<div class="btn-group btn-group-sm btn-group-comparison">
<i ng-repeat="view in $ctrl.myList[0].subList"
class="btn yp-pulseIcon-{{view.icon}}"
ng-click="!$ctrl.disableViews && $ctrl.setView(view)"
ng-disabled="$ctrl.disableViews">
</i>
</div>
I guess that on the second one I must modify something in ng-disabled but all that I've tried so far doesn't work.
Any suggestions?
view.subListof that selected itemng-repeatto enumerate through the lists to generate the buttons? This would be a lot easier to do if you add each button individually in the HTML. Then you can apply certain conditions usingng-disableddirectly. If you do have to do it this way, you can use a JavaScript function in your controller to handle this.ng-repeatbut I don't know with what I must replace the <i ng-repeat> line...<i class="$ctrl.isViewSet('Line','line') ? 'btn-primary' : 'btn-default'" ng-click="!$ctrl.disableViews && $ctrl.setView('Line','line')" ng-disabled="$ctrl.disableViews"></i>for example for the first button (I'm guessing about your JS functions and passed the name and icon of theviewinstead of the view object itself) instead of enumerating throughmyList. You'd have an<i></i>item for each item inmyList. That is essentially whatng-reatdoes. This is just an idea.