Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while running Angular 7 in Google App Script (Google doc Add-on)

I am trying to run Angular cli generated default app, in Google doc add-on (Google App Script) project, As in google app script only .gs and .html files are allowed i have moved all angular's build JS files in script tags and added them as html. But when i run the add-on i am getting this error

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

Directory structure in google app script project

enter image description here

my modified index.html for app-script

<!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>

And here is my code.gs file

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();
}

Is it impossible to run angular in google add-on? or am i missing something?

i already tried adding following to polyfills.ts but no luck

import 'core-js/es7/reflect';

Thanks

like image 531
Haris Jamil Avatar asked Mar 05 '26 17:03

Haris Jamil


1 Answers

According to this other question, How to use AngularJS within Google Apps Script someone suggested to

"move the angular.js include script statement into the head section"

I see yours are in the body section. Change them to the head and it should work.

like image 172
AMolina Avatar answered Mar 08 '26 09:03

AMolina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!