title: Controller isn't counted as a function
body: <p>I have many different controllers throughout this project and all of them are declared the same way. This one now isn't getting called/giving an error and I have no clue why. I've looked through it and it all looks right to me.</p>
  
  <p>I think it's probably some syntax error I'm not seeing. If its something else please tell me. I'm trying to learn angular and everything helps. Also if you need anything else just tell me.</p>
  
  <p>I've made sure its not that the app.js name got changed and been looking for missing syntax but can't find anything.</p>
  
  <p><a href="https://docs.angularjs.org/error/ng/areq?p0=companyDepartmentController&amp;p1=not%20a%20function,%20got%20undefined" rel="nofollow">https://docs.angularjs.org/error/ng/areq?p0=companyDepartmentController&amp;p1=not%20a%20function,%20got%20undefined</a></p>
  
  <p>company-department-controller.js</p>
  
  <pre><code>app.controller('companyDepartmentController', ['$scope', '$timeout', 'companyService', function ($scope, $timeout, companyService) {
  
      /**
      * Create/Manage Company Departments &amp; Shifts
      *
      */
  
      // INITIALIZE VARIABLES *********************************************************************************
  
      var vm = this;
      vm.Departments = [];
      vm.activeDepartment = {}
      vm.departmentBeforeEdit = {};
      vm.activeShift = {};
  
      vm.OffsetString = "";
  
      vm.SaveDepartmentSuccessMessage = null;
      vm.SaveDepartmentErrorMessage = null;
  
      // STARTUP **********************************************************************************************
  
      (vm.GetDepartments = function () {
          companyService.GetDepartmentsWithShiftInformation().success(function (data) {
              console.log('hi');
              for (i = 0; i &lt; data.length; i++) {
                  console.log(data[i])
              }
              vm.Departments = data;
              // for now we are limiting this to 1
              vm.activeDepartment = vm.Departments[0];
              vm.setTimeZoneOffsets(vm.activeDepartment);
          });
      })();
  
      // move to global location?  handle this better?
      (vm.findLocalOffsetString = function () {
          console.log('hi1');
          vm.OffsetString = moment(new Date()).format('ZZ');
      })();
  
      // $BROADCAST/$ON EVENTS ********************************************************************************
  
  
  
      // EVENTS ***********************************************************************************************
  
      vm.saveDepartment = function (department) {
          // new
          if (department.DepartmentID === 0 || typeof department.DepartmentID === 'undefined') {
  
          }
          // update
          else {
              companyService.UpdateDepartmentHeader(department).success(function (data) {
                  vm.SaveDepartmentSuccessMessage = "Saved!";
                  resetDepartmentMessage();
                  department.InEdit = false
              });
          }
      };
  
      vm.editDepartment = function (department) {
          vm.activeDepartment = department;
          vm.departmentBeforeEdit = angular.copy(vm.activeDepartment);
          vm.activeDepartment.InEdit = true;
      };
  
      vm.cancelDepartmentEdit = function (department) {
          for (var i = 0; i &lt; vm.Departments.length; i++) {
              if (department.DepartmentID === vm.Departments[i].DepartmentID) {
                  vm.Departments[i] = vm.departmentBeforeEdit;
                  vm.departmentBeforeEdit = {};
                  vm.activeDepartment = vm.Departments[i];
                  break;
              };
          };
      };
  
      vm.addShift = function () {
          if (!vm.activeDepartment) return;
  
          vm.activeShift = {
              DepartmentID: vm.activeDepartment.DepartmentID,
              StartTime: new Date(),
              LocalStartTime: new Date(new Date() + vm.OffsetString)
          };
  
          vm.activeShift.StartTime.setSeconds(0);
          vm.activeShift.LocalStartTime.setSeconds(0);
      };
  
      vm.deleteShift = function (shift) {
          if (!shift) return;
          if (confirm("Are you sure you want to delete the shift: " + shift.Name + "?")) {
              companyService.DeleteShift(shift).success(function () {
                  angular.forEach(vm.activeDepartment.Shifts, function (c, i) {
                      if (c.ShiftID === shift.ShiftID) {
                          vm.activeDepartment.Shifts.splice(i, 1);
                      };
                  });
              });
          };
      };
  
      vm.setTimeZoneOffsets = function (department) {
          if (!department || !department.Shifts || department.Shifts.length === 0) return;
  
          for (var i = 0; i &lt; department.Shifts.length; i++) {
              department.Shifts[i].LocalStartTime = new Date(department.Shifts[i].StartTime + vm.OffsetString);
              department.Shifts[i].EndTime = moment(department.Shifts[i].StartTime).add(department.Shifts[i].Duration, 'hours').toDate()
          };
      };
  
      var fixTimezoneOnSave = function (shift) {
          shift.StartTime = new Date(shift.LocalStartTime).toLocaleString();
      };
  
      vm.setActiveShift = function (shift) {
          if (!shift) return;
          vm.activeShift = angular.copy(shift);
      };
  
      vm.saveShift = function (shift) {
          fixTimezoneOnSave(shift);
          // new shift
          if (shift.ShiftID === 0 || typeof shift.ShiftID === 'undefined') {
              companyService.AddShift(shift).success(function (data) {
                  shift.ShiftID = data;
                  vm.SaveDepartmentSuccessMessage = "Saved!";
                  resetDepartmentMessage();
                  getUpdatedShiftsAndInfo();
              }).error(function (e) {
                  vm.SaveDepartmentErrorMessage = e.error;
                  resetDepartmentMessage();
              });
          }
          // updating existing
          else {
              companyService.UpdateShift(shift).success(function (data) {
                  vm.SaveDepartmentSuccessMessage = "Saved!";
                  resetDepartmentMessage();
                  getUpdatedShiftsAndInfo();
              }).error(function (e) {
                  vm.SaveDepartmentErrorMessage = e.error;
                  resetDepartmentMessage();
              });
          }
      }
  
      var getUpdatedShiftsAndInfo = function () {
          companyService.DepartmentAndShiftInformation(vm.activeDepartment.DepartmentID).success(function (data) {
              vm.activeDepartment.DepartmentShiftInformation = data.DepartmentShiftInformation;
              vm.activeDepartment.Shifts = data.Shifts;
              vm.setTimeZoneOffsets(vm.activeDepartment);
          });
      };
  
      var resetDepartmentMessage = function () {
          // clear error/success message if they have values still
          if (vm.SaveDepartmentSuccessMessage != null) {
              $timeout(function () { vm.SaveDepartmentSuccessMessage = null; }, 2000);
          }
          if (vm.SaveDepartmentErrorMessage != null) {
              $timeout(function () { vm.SaveDepartmentErrorMessage = null; }, 2000);
          }
      };
  
      // create controller object in console if we have logging turned on
      if (spectrum.LoggingEnabled) {
          spectrum.logController(vm);
      };
  
  }]);
  </code></pre>
  
  <p>_CompanyDepartment.cshtml</p>
  
  <pre><code>&lt;div class="container-fluid" data-ng-controller="companyDepartmentController as cd"&gt;
  &lt;/div&gt;
  
  @section scripts {
      @Scripts.Render("~/bundles/companyDepartments")
      @Scripts.Render("~/bundles/jquery")
      @Scripts.Render("~/bundles/angularjs")
  }
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var app = angular.module('app', ['angularFileUpload', 'ngSanitize', 'ui.mask', 'ui.select', 'ui.bootstrap', 'ui.bootstrap.tpls', 'angular.filter', 'smart-table', 'colorpicker.module'])
      .config(function ($httpProvider) {
          //make delete type json to facilitate passing object
          //to our generic method.
          $httpProvider.defaults.headers["delete"] = {
              'Content-Type': 'application/json;charset=utf-8'
          };
      });
  </code></pre>