I put the init() function outside of the return of my directive :
app.directive('myDirective', function()
{
return {
restrict: 'C',
controller: function($scope)
{
init($scope);
}
}
function init($scope)
{
$scope.params = [];
// Other initializations
}
});
Is this bad practice or a bad idea? I just don't like to have the init() inside the controller since I feel that things inside the controller are meant to be reused and run continuously.
One of my reasoning for putting it at the end is that initialization happens once, and I want to place it at the very bottom of the code, where it doesn't bother me, and doesn't steal space from my other code that I spend more time on.
What do you think/suggest?