【发布时间】: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