AngularJS. I have
app.service('list', function () { .. get $('#list') .. });
app.service('grid', function () { .. get $('#grid') .. });
app.controller('myController',['$a', 'list', 'grid', function ($a, list, grid) {
if ($scope.isList)... list
if ($scope.isGrid)... grid
}]);
When my $scope.isList
I don't need the "grid
" service (because is undefined)
I understand that this could be done in an other way, using separate controllers, etc etc...
But my main question is: Is it possible to conditionally include dependent services?
Say by eg:
app.controller('myController',['$a', function ($a) {
if ($scope.isList)... thisController.AddDependency('list', list);
if ($scope.isGrid)... thisController.AddDependency('grid', grid);
}]);