Though the title may not capture it quite accurately, I struggled to find a more fitting description.
I crafted a directive that incorporates an ng-repeat
:
app.directive('appDirective', function($purr){
var template = '' +
'<div ng-repeat="elements in queue">' +
'</div>';
return{
template: template
}
});
If my understanding is correct, there are two ways I can provide the queue
to my directive
1: via the linking function
return{
restrict: 'A',
template: template,
link: function(scope){
scope.queue =[];
}
}
2: through the controller
return{
restrict: 'A',
template: template,
controller: directiveCtrl
}
app.controller('directiveCtrl',function($scope){
$scope.queue = [];
});
Which method should I select and what are the reasons behind that choice?