How do I define a static property for a class in ES6?
Let's consider the scenario: I previously had a factory named Commands.
commandsFactory.js
angular.module('mainModule')
.factory('Commands', [function () {
return{
// multiple commands listed here
}
This factory was utilized as a dependency in another factory known as Module:
moduleFactory.js
.factory('K_Module', ['Commands', function (Commands) {
// Commands were consistently used within this factory
// all instances generated by this factory were granted access to Commands
}
Following my coding transformation, the following changes took place:
commandFactory.js
function CommandsFactory() {
return collection of all commands
}
export {
CommandsFactory
}
I created a new file to export a module named
data.module.js
import $parser from '../parsers/parsers.module';
import $communication from '../communication/communication.module';
import {Connectors, CommandsFactory} from './Commands'
export default require('angular')
.module('core.data', [$parser, $communication])
.factory("Connectors", Connectors)
.factory("Commands", CommandsFactory)
.name;
This module is invoked in another module named
kModule
import $data from '../core/data/data.module';
import {K_Module, K_Matrix} from './ModuleFactory'
export default require('angular')
.module('kModules', [$data])
.service('K_Module', K_Module)
.name;
The revised K_Module structure looks like this (and poses a question):
class K_Module {
constructor(data, Commands, DataProxy, $q) {// I want to avoid specifying these dependencies (except data) every time I create a K_Module
'ngInject';
let _self = this;
_self.Commands = Commands;
_self.DataProxy = DataProxy;
_self.$q = $q;
//... additional details
Is there a way to convert Commands, $q, and DataProxy into static properties? This would facilitate inheritance of these properties without repeated declarations. var