如何谷歌Apps脚本中使用AngularJS [英] How to use AngularJS within Google Apps Script
问题描述
时有可能使用Angular.js作为一个web应用程序的一部分,在谷歌Apps脚本使用HtmlService服?
Is it possible to use Angular.js as part of a web app served using HtmlService in Google Apps Script?
我也改变了 code.gs
下面链接中提到的文件。结果
<一href=\"http://stackoverflow.com/questions/12737033/how-can-i-use-angular-js-in-a-google-apps-script-served-html-site\">How我可以使用Angular.js在谷歌Apps脚本提供HTML的网站?
但没有得到成功。
来源$ C $ C:
code.gs
Code.gs
function doGet(request) {
return HtmlService.createTemplateFromFile('index')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent()
}
index.html的
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
Javascript.html
<script>
var app = angular.module('myApp',[]);
app.controller('mainCtrl',function($scope) {
$scope.heading = 'Welcome';
$scope.message = 'Please enjoy this helpful script';
});
</script>
输出我得到控制台:
错误在解析沙盒属性:让-情态动词,
让 - 弹出窗口对逃逸的沙箱'是无效的沙箱标志。开发:14结果
未捕获的ReferenceError:角没有定义VM4501:2结果未捕获
对象
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
任何直接的帮助将是非常美联社preciable。
Any immediate help will be highly appreciable.
推荐答案
移动angular.js包括脚本语句转换成头部分。它需要包括剩余的javascript文件之前进行设置。它的工作原理呢。点击此处查看:
<一href=\"https://script.google.com/macros/s/AKfycbxj2FID2RI2QvdrwdujLm9FUpP5YIE3zjv5CGC3zeBX3ch7M1M/exec\"相对=nofollow> GAS-angularJS
Move the angular.js include script statement into the head section. It needs to be setup before the remaining javascript file is included. It works then. check it here: GAS-angularJS
这篇关于如何谷歌Apps脚本中使用AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!