2016-09-16 3 views
-2

구글 스크립트에서 각도, 으로 어플리케이션을 코딩하려고하는데, 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> 

내 자바 파일, 나는 오류가 내 자바 파일에 각 라이브러리

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

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

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

에게 인식 "오류 ReferenceError를"각 "정의되지 않았습니다. (행 2)"

감사합니다.

+0

'https '없이 js를로드하려고합니다. – Vineet

+0

파일과 함께 직접로드하려고 했으므로 부트 스트랩에있을 때 제대로 작동했습니다. 그러나 Google 시트에 복사했을 때 효과가 없었습니다. 그리고 내 프로젝트에서 .js를 직접 가져올 수 없었습니다. –

+0

1) java? 그 자바가 아니야. 2) .gs는 각도와 관련이 없습니다. 너는 .js를 의미하는거야? Google 스크립트의 –

답변

0

더 많은 변경 작업이 필요합니다.

각도 예 GAS 구조 : 작동하는 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 그것은 당신의 코드를 사용하지 않고, 당신이 쉽게 적응 확신

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

<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.

감사합니다!

관련 문제