Skip to content

Instantly share code, notes, and snippets.

@sptq
Last active November 23, 2016 22:53
Show Gist options
  • Save sptq/6eb1da844eb6b023dd9a04264a113e51 to your computer and use it in GitHub Desktop.
Save sptq/6eb1da844eb6b023dd9a04264a113e51 to your computer and use it in GitHub Desktop.
Angular 1.5.x Controller Class
/**
* Lodash version
*/
import {assign, each} from 'lodash';
export default class ResourceLookupController {
constructor() {
each(arguments, (o, i) => assign(this, {[this.constructor.$inject[i]] : o}));
this.name = 'resource-lookup';
}
sendGet() {
this.output = this.resourceLookupService.doGetRequest()
}
scopeManipulation() {
this.$scope.test = 'test';
}
}
ResourceLookupController.$inject = ['$scope', 'resourceLookupService'];
/**
* Vanilla JS version
*/
export default class ResourceLookupController {
constructor() {
[...arguments].forEach((o, i) => Object.assign(this, {[this.constructor.$inject[i]] : o}));
this.name = 'resource-lookup';
}
sendGet() {
this.output = this.resourceLookupService.doGetRequest()
}
}
ResourceLookupController.$inject = ['resourceLookupService'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment