Skip to content

Instantly share code, notes, and snippets.

@carlosrymer
Created July 30, 2017 15:42
Show Gist options
  • Save carlosrymer/551f9c7ea87e6576773f325c2cd81639 to your computer and use it in GitHub Desktop.
Save carlosrymer/551f9c7ea87e6576773f325c2cd81639 to your computer and use it in GitHub Desktop.
A sample ES6 Angular 1.x, class-based controller.
class SampleCtrl {
constructor($scope, Service1, Service2) {
'ngInject';
this.$scope = $scope;
this.Service1 = Service1;
this.Service2 = Service2;
$scope.$on('event:sample1', () => this.doSomethingOne());
$scope.$on('event:sample2', () => this.doSomethingTwo());
}
doSomethingOne() {
this.Service1.exec();
}
doSomethingTwo() {
this.Service2.exec();
}
}
export default SampleCtrl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment