我已经使用Office Yeoman工具创建了Angular Outlook插件
https://github.com/OfficeDev/generator-office
在app.component.html中,我像这样设置了一个简单的TextField,
<div class="ms-TextField">
<input class="ms-TextField-field" type="text" value="" placeholder={{name}}>
</div>
在app.component.ts中,我想将当前开始日期和时间作为文本放入该文本字段中,但是却难以理解如何使用angular ts文件中提供的javascript函数。
Office.context.mailbox.item.start.getAsync(function (asyncResult) {
if (asyncResult.status === "failed") {
console.log("Action failed with error: " + asyncResult.error.message);
}
else {
console.log("Start date and time: " + asyncResult.value);
}
});
如何使用此回调的结果填充名称,以及如何使JavaScript在TS文件中起作用?
App.Component.TS
import { Component } from '@angular/core';
const template = require('./app.component.html');
@Component({
selector: 'app-home',
template
})
export default class AppComponent {
name = 'Loading...';
// ADD CODE HERE TO SET NAME TO START DATE AND TIME
async run() {
}
}
我尝试使用Office.context.mailbox.item.start.getAsync,但是Office命令仅在将其设置为变量值的情况下才可行。我无法像文档建议那样使它运行,并且无法使用Angular for Office.Js查找任何示例,在该示例中,他们使用这些Async方法获取Outlook。任何想法或帮助表示赞赏。