[英]How do I make AngularJS work in Google Apps Script?
I am currently following this tutorial: https://scotch.io/tutorials/build-a-real-time-scheduling-app-using-angularjs-and-firebase#connecting-to-and-using-firebase , but it is not working as I have it in Google Apps Script. 我目前正在关注本教程: https : //scotch.io/tutorials/build-a-real-time-scheduling-app-using-angularjs-and-firebase#connecting-to-and-using-firebase ,但这是无法正常使用,因为我在Google Apps脚本中使用了它。
I am trying to use AngularJS
in Apps Scripts
. 我正在尝试在
Apps Scripts
使用AngularJS
。 However, the documented fixes to make AngularJS
work is documented to use the following line of code: 但是,记录的使
AngularJS
正常运行的修复程序记录为使用以下代码行:
var ui = HtmlService.createHtmlOutputFromFile('myPage')
.setTitle('My Title');
ui.setSandboxMode(HtmlService.SandboxMode.IFRAME);
Source: Angular JS in Google Apps Script 来源: Google Apps脚本中的Angular JS
But I am not sure where to put this in my Code.gs
file? 但是我不确定将其放在
Code.gs
文件中的什么位置? I have a function.doGet
, so does it go in there? 我有一个
function.doGet
,那它放在那里吗?
Right now, my Code.gs
is as follows: 现在,我的
Code.gs
如下:
function doGet() {
return HtmlService.createHtmlOutputFromFile('index')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
Thanks for your help! 谢谢你的帮助!
HtmlService.createOutputFromFile(...)
returns an instance of the HtmlOutput
class, which has the setSandboxMode(..)
method. HtmlService.createOutputFromFile(...)
返回HtmlOutput
类的实例,该类具有setSandboxMode(..)
方法。 Assuming that you have a file "index.html" in your Apps Script project, your code is correct: 假设您的Apps Script项目中有一个文件“ index.html”,那么您的代码是正确的:
function doGet() {
return HtmlService.createHtmlOutputFromFile('index')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
doGet
is the method called by the Apps Script runtime when user navigates to your app's URL, and it should return the fully formed HTML that you want to render (which can include references to externally hosted js, css, etc.) doGet
是当用户导航到应用程序的URL时由Apps Script运行时调用的方法,它应返回要呈现的完整HTML(可以包括对外部托管的js,css等的引用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.