2016-09-16 41 views
-2

我想代碼在谷歌腳本與Angular應用程序, ,所以我宣佈角度在我的HTML文件(和它的作品),但是,我的.gs文件不明白角功能。這不包括在谷歌腳本角

我的HTML(行之有效)

<html ng-app="gemStore"> 
<head> 
     <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script> 
     <script type="text/javascript" src="main.gs"></script> 
</head> 
<body> 
... 
</body> 
</html> 

和我的Java文件識別角度庫

(function() { 
var app = angular.module('gemStore', []); 

app.controller('StoreController', function(){ 
this.product = gems; 
}); 

var gems = 
{ name: 'Azurite', price: 2.95 } 
; 
})(); 

在我的java文件,我有一個錯誤 「的ReferenceError:」 角「沒有定義。(2號線)」

感謝

+0

嘗試加載沒有'https'的js。 – Vineet

+0

我試圖直接加載它,所以當我在Bootstrap中運行良好。但是當我將它複製到Google表單上時,它沒有奏效。並且我沒有設法直接導入我的項目上的.js –

+0

澄清1)java?它不是java。 2).gs與角度無關。你的意思是.js?谷歌腳本中的 –

回答

0

你需要做更多的昌ES爲它工作,我在這裏做一個例子:

角例油氣構造:

的index.html

<!DOCTYPE html> 
    <?!= include('js'); ?> 

<html> 
    <head> 
    <base target="_top"> 
    <?!= include('css'); ?> 
    </head> 
    <body> 
    <div > 


<div ng-app="gemStore"> 
    <div ng-controller="StoreController"> 
    <h1>Write here</h1> 
     <input ng-model="name" ng-keyup="NameChange()"> 
     <h1>{{greeting}}</h1> 
     <h2>{{name}}</h2> 
    </div> 

    </div> 

    </div> 
    </body> 
</html> 

Core.gs

function doGet(e) { 
    var t = HtmlService.createTemplateFromFile('index'); 
    return t.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME).setTitle('Angular Example By Daniel C'); 
} 
function include(filename) { 
     return HtmlService.createHtmlOutputFromFile(filename) 
      .getContent(); 
    } 

js.html

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> 
<script> 

    angular.module('gemStore', []) 
     .controller('StoreController', function($scope) { 
      $scope.NameChange = function() { 
       $scope.greeting = "Hello " + $scope.name; 
      }; 
     }); 

</script> 

css.html

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> 
<style> 
/*your styles here*/ 
</style> 

它不使用你的代碼,但我相信你會很容易適應它。

謝謝!