While delving into the world of angular1, I encountered services and factories. Using the .factory()
method, I passed in a string that represented the desired service name. Surprisingly, I found myself able to reference a variable matching this string without actually creating it explicitly. This led me to wonder about the underlying mechanism at play here. Could it be related to dependency injection? The way angular/js achieves this auto-variable creation eludes my current understanding.
app.factory('myData', function() {
return {...}
}
app.controller('MyController',
function MyController($scope, myData) {
...
}
);