I am creating an ionic mobile application which will notify the user of the app when they have some unread mail from their office 365 account. I have spent hours on this piece of code trying to figure out where it is going wrong. if anyone can find a reason why this piece of code isn't working, that would be much appreciated. Thank you.
(function () {
'use strict';
angular.module('app365').controller('homeCtrl', ['$scope', '$stateParams', '$ionicLoading', '$ionicPopup', 'app365api', homeCtrl]);
function homeCtrl($scope, $stateParams, $ionicLoading, $ionicPopup, app365api) {
var vm = this;
var outlookClient;
// Get mail list.
function getMails() {
var filterQuery = '';
// Get all mails flagged as important.
if (typeof $stateParams.important != 'undefined') {
getImpMails();
return;
}
// Get all unread mails.
if (typeof $stateParams.unread != 'undefined') {
filterQuery = 'IsRead eq false';
}
NProgress.start();
// Fetch Inbox folder
outlookClient.me.folders.getFolder("Inbox").messages.getMessages().filter(filterQuery).fetch()
.then(function (mails) {
// Get current page. Use getNextPage() to fetch next set of mails.
vm.mails = mails.currentPage;
$scope.$apply();
NProgress.done();
});
};
if ($scope.result() == null) {
null;
} else {
$ionicPlatform.ready(function () {
$ionicPopup.confirm({
title: "You have unread mail",
})
.then(function (result) {
if (!result) {
ionic.Platform.exitApp();
}
});
}
)
}
}
}
)
Error: [ng:areq] Argument 'homeCtrl' is not a function, got undefined
This is the error I receive even though homeCtrl is a function and had already been referenced.