Answer the question
In order to leave comments, you need to log in
How to access the parent scope through ng-repeat?
There is a pattern
<div class="hockey-DateBlock" ng-repeat="key in ['13 мая', '14 мая', '15 мая', '16 мая', '17 мая', '18 мая', '19 мая', '20 мая']" ng-class="{'active' : $index == ActiveId}">
{{key}}
</div>
scope.activeId = function () {
return currentIndex + 1;
}
Answer the question
In order to leave comments, you need to log in
Solved the problem by passing a two-way link from the directive to the component, and then comparing with the component's variable in ng-repeat
<div class="hockey-Date"
hockey-date-scroll
hds-item-width="50"
hds-active-id="$ctrl.activeId"
hds-items-length="8">
<div class="hockey-DateBlock" ng-repeat="date in $ctrl.dates" ng-class="{'active' : $index == $ctrl.activeId}">
{{date}}
</div>
</div>
scope: {
activeId: '=hdsActiveId'
},
Use controller syntax as
jsbin.com/rokejinite/edit?html ,css,js,output
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question