【问题标题】:How to use AngularJS within Google Apps Script如何在 Google Apps 脚本中使用 AngularJS
【发布时间】:2016-02-25 07:26:23
【问题描述】:

是否可以将 Angular.js 用作使用 Google Apps 脚本中的 HtmlService 提供的网络应用程序的一部分?

我还更改了 Code.gs 文件,如下面的链接所述。
How can I use Angular.js in a Google Apps Script served HTML site?

但没有成功。

源代码:

Code.gs

function doGet(request) {
  return HtmlService.createTemplateFromFile('index')
      .evaluate()
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

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

index.html

<!DOCTYPE html>
<html ng-app="myApp">
  <head>
    <base target="_top">
  </head>
  <body ng-controller="mainCtrl">
    <h1>{{heading}}</h1>
    <p>{{message}}</p>
    <?!= include('Javascript'); ?>
     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script>
  </body>
</html>

Javascript.html

<script>
var app = angular.module('myApp',[]);
app.controller('mainCtrl',function($scope) {
  $scope.heading = 'Welcome';
  $scope.message = 'Please enjoy this helpful script';
});
</script>

我在控制台中得到的输出:

解析“沙盒”属性时出错:“允许模式”, 'allow-popups-to-escape-sandbox' 是无效的沙箱标志。开发:14
未捕获的 ReferenceError:未定义角度 VM4501:2
未捕获 对象

任何即时的帮助都将是非常可观的。

【问题讨论】:

    标签: angularjs google-apps-script


    【解决方案1】:

    将 angular.js 包含脚本语句移动到 head 部分。它需要在包含剩余的 javascript 文件之前进行设置。然后就可以了。在这里检查: GAS-angularJS

    【讨论】:

      猜你喜欢
      • 2020-10-23
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      • 2017-08-28
      • 1970-01-01
      • 1970-01-01
      • 2016-06-26
      相关资源
      最近更新 更多