angular controller best practices

Is it ok to do this :

.controller('ComputeCtrl', function($scope, $ionicPopup, $timeout, sessionService) {...})

or we should better write the dependencies like this :

.controller('ComputeCtrl', ['$scope', '$ionicPopup', '$timeout', 'sessionService', function($scope, $ionicPopup, $timeout, sessionService) {...}])

In the ionic starter app, the first version is used.

Thanks

The second syntax is used, when you want to minify your code. Because the variable names get renamed from $scope to something like a, angularjs won't be able to determine, which module you want to inject. Because of that, you provide a string that tells angular, which module do you want.

If you don't want to minify your code, you can safely use the first syntax.

If you don't like the second syntax, but you want to minify your code, you can use ngAnnotate https://github.com/olov/ng-annotate which will add the annotations for the second syntax on build time (maybe along with grunt-ng-annotate https://www.npmjs.org/package/grunt-ng-annotate).

Since the seed project is not using minification stuff, it is fine written in first way.

But if you are considering minification make sure you use second version.