AngularJS 'service' goes from being the red headed step child to the golden child

I have a confession to make, I did not have a single service that was created and registered using service in my massive AngularJS app before migrating to ES6. They were mostly created using factory and where appropriate, created using provider - but not a single one with service. I just preferred how factory felt and looked. Providers, though verbose, were the only way to make a service configurable. Surprisingly, I found that I wasn't the only one in this conspiracy against services. In fact, I have read multiple blog posts where people have outright dissed services and recommended using factory.

Through my journey migrating this same app to ES6, my feelings to this often neglected style have changed. It has become my go to approach now. Why you say this change of heart? Well, it is because ES6 classes lend themselves very well to services. They plug right in. This is also how I create controllers. I like this idea of being able to follow the same pattern to create controllers and services. I wish I could create directives the same way but unfortunately it needs be a function that returns a directive definition object.

export class Security {  
  constructor() {
    this._permissions = ['deleteUsers'];
  }

  get username() {
    return "Don Joe";
  }

  isAdmin() {
    return true;
  }

  checkAccess(permission) {
    return this._permissions.find(perm => perm === permission);
  }
}

This class can be simply plugged into the service registration function:

import {Security} from "security";

var app = angular.module('plunker', [])  
            ....
            .service('security', Security)
            ......

With all the news post ng-europe about AngularJS 2.0 and how everything is going to be built around ES6 classes and modules, I am hoping that this approach would leave me in a better place when it is time to migrate over to AngularJS 2.0. I am not going to be naive and expect it to be smooth migration, but I am hoping that these tiny steps today will alleviate some pain in the future. Hopefully my classes will be directly pluggable into whatever the equivivalent or replacement for services will be (if any) or maybe it will be as simple as just adding the appropriate annotations to my existing classes so that they act like controllers or services. Fingers crossed.