import { app } from '../app.module';

app.factory('dataTransfer', [function () {

  let watcher;
  let templates;

  const dataTransfer = {
    getWatcher: function () {
      return watcher;
    },
    setWatcher: function (_watcher_) {
      watcher = _watcher_;
    },
    setTemplates: function (_templates_) {
      templates = _templates_;
    },
    getTemplates: function () {
      return templates;
    }
  };

  return dataTransfer;

}]);

import { app } from '../app.module';

class DataTransfer {

  constructor() {
    this.watcher;
    this.templates;
  }

  getWatcher() {
    return this.watcher;
  }

  setWatcher(_watcher_) {
    this.watcher = _watcher_;
  }

  setTemplates(_templates_) {
    this.templates = _templates_;
  }

  getTemplates() {
    return this.templates;
  }

};

app.factory('dataTransfer', () => new DataTransfer());

Refactor dataTransfer factory to ES6 syntax.