I have directive with this template that includes a repeater:
template: '<div class="btn-group">' +
'<a href="javascript:void(0)" class="btn" ng-repeat="option in options" ng-click="select($event, scope)" value="{{option.value}}">{{option.label}}</a>' +
'</div>'
Inside my link function, the following returns an empty array unless I put it inside a $timeout:
var tmp = element.find('.btn');
Link to fiddle: http://jsfiddle.net/dkrotts/XF3RY/1/
Shouldn’t these elements be available at link time? If not, is there a cleaner way to handle this situation?
Apparently the ng-repeat happens later, after your link function is run: https://stackoverflow.com/a/13771751/215945
You may want to try using two directives, similar to the
tabsandpanedirectives on the Angular home page example. Theradio-buttonsdirective could define a method (usingthis) on its controller that theradio-buttondirective could call when clicked.For details on how the tabs and pane directives communicate, see https://stackoverflow.com/a/14168699/215945