【问题标题】:Error while running Angular 7 in Google App Script (Google doc Add-on)在 Google App Script(Google doc Add-on)中运行 Angular 7 时出错
【发布时间】:2019-05-31 06:15:29
【问题描述】:

我正在尝试在 Google doc add-on (Google App Script) 项目中运行 Angular cli 生成的默认应用程序,因为在 google 应用程序脚本中只允许使用 .gs 和 .html 文件,我已将所有 angular 的构建 JS 文件移入脚本标签并将它们添加为 html。但是当我运行插件时,我得到了这个错误

userCodeAppPanel:6862 Uncaught Error: Can't resolve all parameters for ApplicationModule: (?).
    at syntaxError (userCodeAppPanel:6862)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (userCodeAppPanel:22346)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (userCodeAppPanel:22241)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (userCodeAppPanel:22109)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (userCodeAppPanel:21920)
    at userCodeAppPanel:22033
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (userCodeAppPanel:22021)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleSummary (userCodeAppPanel:21920)
    at userCodeAppPanel:22006

谷歌应用脚​​本项目中的目录结构

我为 app-script 修改的 index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>AngularAddOn</title>

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>

  <?!= include('runtime.js');?>
  <?!= include('vendor.js');?>
  <?!= include('styles.js');?>
  <?!= include('main.js');?>
  <?!= include('polyfills.js');?>
  <?!= include('es2015-polyfills.js');?>

  <app-root></app-root>
</body>
</html>

这是我的 code.gs 文件

function myFunction() {

}
function onOpen(e) {
  DocumentApp.getUi().createAddonMenu()
    .addItem('Manage Citations', 'showSidebar')
    // .addItem("test dialog", 'showDialog')
    .addToUi();
}

function showSidebar() {
  var html = HtmlService.createTemplateFromFile('index').evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).setTitle('wizdom.ai');
  DocumentApp.getUi().showSidebar(html);
}

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename).getContent();
}

在 google 插件中运行 Angular 是不可能的吗?还是我错过了什么?

我已经尝试在 polyfills.ts 中添加以下内容,但没有成功

import 'core-js/es7/reflect';

谢谢

【问题讨论】:

标签: angular google-apps-script google-docs


【解决方案1】:

根据this other question,How to use AngularJS within Google Apps Script有人建议

“将 angular.js 包含脚本语句移动到头部”

我看到你的在正文部分。将它们更改为头部,它应该可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-30
    • 2020-10-01
    • 1970-01-01
    相关资源
    最近更新 更多