Get rid of `this` in your JavaScript code(programming.oreilly.com) |
Get rid of `this` in your JavaScript code(programming.oreilly.com) |
In any case, I like this. I've struggled with javascript's weird `this` scope in the past. And this also avoids the `new` operator, which I also feel doesn't really belong in javascript.
var serviceInterface = {};
// a bunch of code for the service/factory/provider
return serviceInterface;
I personally think of services/factories/providers as "implementation details" which I group as "client-side services". "Services" in this phrase does not have the same meaning as "service" in Angularese, and this helps me think more clearly more often than not about how my code relates to my goal, so "serviceInterface" is really a shorthand for "clientsideServiceInterface".