The title may be a bit misleading, but i could not think of a better description.
I wrote a directive which includes a ng-repeat
:
app.directive('appDirective',function($purr){
var template = '' +
'<div ng-repeat="elements in queue">' +
'</div>';
return{
template: template
}
});
If i'm correct, i can choose between two ways of providing queue
to my directive
1: via linking function
return{
restrict: 'A',
template: template,
link: function(scope){
scope.queue =[];
}
}
2: via controller
return{
restrict: 'A',
template: template,
controller: directiveCtrl
}
app.controller('directiveCtrl',function($scope){
$scope.queue = [];
});
Which way should i choose, and why?