Are the two examples below equivalent?
1.
app.controller('ctrl',function($scope){});
2.
app.controller('ctrl',['$scope',function($scope){});
I'm new to AngularJs. From my test, they do the same thing, but not sure why there are two different ways.
They will function the same way, but usually the second method is preferred. This has to do with minification and the fact that when you distribute your app it's a possibility variable names will be changed if they aren't items within an array.
Of course if your controller names change during minification this will cause Angular's dependency injection to fail.