I seem to come across an error when I try to define a controller within a directive that is wrapped in an IIFE. Although I could fixed this by adding ng-controller on the div in tableHelper.html. I was wondering the code below returns tableHelperCtrl as undefined.
Using angular.js 1.2.29
app.module.js
(function () {
    'use strict';
    angular.module('app', [
    ]);
})();
tableHelper.controller.js
(function () {
    'use strict';
    angular
        .module('app')
        .controller('tableHelperCtrl', tableHelperCtrl);
    function tableHelperCtrl() {
        var vm = this;
        vm.data = 'some data'
    }
})();
tableHelper.directive.js
(function () {
    'use strict';
    angular
        .module('app')
        .directive('tableHelper', tableHelper);
    function tableHelper() {
        var directive = {
            restrict: 'A',
            templateUrl: './src/app/tableHelper/tableHelper.html',
            link: link,
            controller: tableHelperCtrl,
            controllerAs: 'vm'
        };
        return directive;
        }
    }
})();
tableHelper.html
<div>
    <p>Table Helpers Directive</p>
    <table>
        <thead></thead>
        <td>{{vm}}</td>
    </table>
</div>
 
     
     
     
    