Angular アプリを作成し、それにJS APIライブラリを使用したいと考えました。Office 365 Outlook 内でこのアプリを使用したいと考えています。ただし、次のエラーが発生します。
Uncaught TypeError: window.external.GetContext is not a function
OSF.InitializationHelper.getAppContext @ o15apptofilemappingtable.js:11
私はブラウザーで index.html を実行していますが、最終的には Office 365 Outlook 内から実行します。以下はコードです:
index.html:
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Office 365 APIs sample</title>
<base href="/">
...
...
<!-- JavaScript Office API -->
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" type="text/javascript"></script>
<!-- App code. -->
<script src="scripts/app.js"></script>
<script src="controllers/homeController.js"></script>
</head>
<body>
</body>
</html>
app.js:
(function () {
console.log("STARTING...");
var init = function (reason) {
$(document).ready(function () {
console.log("ready");
});
};
try {
Office.initialize = init;
if(!window.external.GetContext) {
console.log('Not in office context');
init();
}
} catch(e) {
// when in office context unable to access external
console.log(e);
}
});
誰かがこのエラーに遭遇した場合はお知らせください。Webで検索しても解決策が見つかりませんでした。
ありがとう!