通过 Office 365 应用程序(离子移动应用程序)通知未读邮件
Notify when unread mail through office 365 app(ionic mobile app)
我正在创建一个 ionic 移动应用程序,当用户有一些来自其 office 365 帐户的未读邮件时,该应用程序将通知该应用程序的用户。我在这段代码上花了几个小时试图弄清楚哪里出了问题。如果有人能找到这段代码不起作用的原因,将不胜感激。谢谢。
(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
这是我收到的错误,即使 homeCtrl 是一个函数并且已经被引用。
您在最后缺少调用 IIFE 的 ()
。因此控制器未被注册,因为该功能从未运行。
改变
(function() {
'use strict';
angular.module('app365').controller('homeCtrl', ['$scope', '$stateParams', '$ionicLoading', '$ionicPopup', 'app365api', homeCtrl]);
function homeCtrl($scope, $stateParams, $ionicLoading, $ionicPopup, app365api) {
// code removed for clarity
}
}
)
到
(function() {
'use strict';
angular.module('app365').controller('homeCtrl', ['$scope', '$stateParams', '$ionicLoading', '$ionicPopup', 'app365api', homeCtrl]);
function homeCtrl($scope, $stateParams, $ionicLoading, $ionicPopup, app365api) {
// code removed for clarity
}
})();
//^^ missing braces
我正在创建一个 ionic 移动应用程序,当用户有一些来自其 office 365 帐户的未读邮件时,该应用程序将通知该应用程序的用户。我在这段代码上花了几个小时试图弄清楚哪里出了问题。如果有人能找到这段代码不起作用的原因,将不胜感激。谢谢。
(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
这是我收到的错误,即使 homeCtrl 是一个函数并且已经被引用。
您在最后缺少调用 IIFE 的 ()
。因此控制器未被注册,因为该功能从未运行。
改变
(function() {
'use strict';
angular.module('app365').controller('homeCtrl', ['$scope', '$stateParams', '$ionicLoading', '$ionicPopup', 'app365api', homeCtrl]);
function homeCtrl($scope, $stateParams, $ionicLoading, $ionicPopup, app365api) {
// code removed for clarity
}
}
)
到
(function() {
'use strict';
angular.module('app365').controller('homeCtrl', ['$scope', '$stateParams', '$ionicLoading', '$ionicPopup', 'app365api', homeCtrl]);
function homeCtrl($scope, $stateParams, $ionicLoading, $ionicPopup, app365api) {
// code removed for clarity
}
})();
//^^ missing braces