Given this very simplistic markup:
<div ng-repeat="item in items" item>
And the directive:
app.directive('item', function()
{
return function(scope, element, attrs)
{
}
})
Say on a click event, I want to get the next item's scope and do something. I can either use scope.$$nextSibling()
or element.next().scope()
.
Is there an advantage/disadvantage of using either? Or is there a better way of getting the next sibling's scope?
you should do like this in the scope, call $rootScope.$broadcast('SOME_CHANGE_IN_SCOPE',...); in sibling scope, call $scope.$on('SOME_CHANGE_IN_SCOPE',...) you can of course wrap data in the event, check angularjs doc for more details