Rewriting Angular Controller Using ES6 Syntax

Migrating existing angular controller from ES5 to ES6 is relatively easy.
Here is an example of angular controller written in ES5.

angular.module('corporateChallengeApp')
       .controller('DashboardCtrl', DashboardCtrl);
    DashboardCtrl.$inject = [
         'sportService',
         'Auth',
         'sportUtils'];
    function DashboardCtrl(sportService, Auth, sportUtils) {

        var vm = this;
        vm.sports = [];
        vm.mySports = [];
        vm.initialized = false;
        vm.currentUser = Auth.getCurrentUser();

        init();

        function init() {
            getSports();
        }

        function getSports() {
            var year = new Date().getFullYear();
            return sportService.getSports(year)
                .then(function (data) {
                    vm.sports = data;
                    vm.mySports = sportUtils.getSportsByUser(vm.sports,vm.currentUser);
                    vm.initialized = true;
                    return vm.sports;
                });
        }

    }

Now let’s write the above controller using ES6 Syntax

    class DashboardCtrl {
        /*@ngInject*/
        constructor(sportService, Auth, sportUtils) {
            this.sportService = sportService;
            this.Auth = Auth;
            this.sportUtils = sportUtils;
            this.sports = [];
            this.mySports = [];
            this.initialized = false;
            this.currentUser = Auth.getCurrentUser();
            this.getSports();
        }

        getSports() {
            var year = new Date().getFullYear();
            return this.sportService.getSports(year)
                .then(data => {
                    this.sports = data;
                    this.mySports = this.sportUtils.getSportsByUser(this.sports, this.currentUser);
                    this.initialized = true;
                    return this.sports;
                });
        }
    }
    angular.module('corporateChallengeApp')
           .controller('DashboardCtrl', DashboardCtrl);

Now you’ll need to use transpiler like Babel to transpile it down to ES5 when you build your project.
This only uses the class and arrow function feature, there are many other features in ES6.