I am experimenting with Angular Seed and I tried to add a $scope
dependency to the View1Ctrl
as follows:
.controller('View1Ctrl', [function ($scope) {
$scope.message = 'mundo';
}]);
which does not work: $scope
is undefined
...
When I change the code to this:
.controller('View1Ctrl', function ($scope) {
$scope.message = 'mundo';
});
then $scope
is resolved.
Can someone please explain why $scope
is not resolved with the first snippet?
if you use the [] you need to provide strings to match the dependency's to inject.
This is useful if you minify your javascript,
This means the $scope is injected as a variable named a. Without the [] it attempts to inject whatever the variable name is.