是否可以将Angular.js作为在Google Apps脚本中使用HtmlService服务的Web应用程序的一部分?如何在Google Apps脚本中使用AngularJS
我还更改了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>
输出我得到控制台:
Error while parsing the 'sandbox' attribute: 'allow-modals', 'allow-popups-to-escape-sandbox' are invalid sandbox flags. dev:14
Uncaught ReferenceError: angular is not defined VM4501:2
Uncaught object
任何直接的帮助将是非常可观的。
Thanks..its working :) –