私はangleを使って小さなウィジェットを構築しています。このwidgetは、ユーザーから与えられたGoogleシートIDを受け取り、素晴らしいjson形式で出力を公開します。問題は私のコードが何もしないことです。そこにはエラーがコンソールにありませんし、私はIDを何も追加しないときサービスを設定してGoogleシートIDを渡すにはどうすればよいですか? AngularJS
が、私は問題がservice.js
angular.module('adf.widget.charts')
.service('chartService', function(){
return {
getUrl: function(key){
var googleSheetkey = key
}
}
return googleSheetkey
});
edit.html(追加するためのシートID)であると思いますが起こる
<form role="form">
<div class="form-group">
<label for="sample">Sample</label>
<input type="text" class="form-control" id="sample" ng-model="config.googleSheetkey" placeholder="Enter path">
</div>
</form>
App.js
angular.module('adf.widget.charts', ['adf.provider', 'nvd3'])
.config(function(dashboardProvider){
var widget = {
templateUrl: '{widgetsPath}/charts/src/view.html',
reload: true,
resolve: {
/* @ngInject */
urls: function(chartService, config){
if (config.key){
return chartService.getUrl(config.googleSheetkey);
}
}
},
edit: {
templateUrl: '{widgetsPath}/charts/src/edit.html'
}
};
dashboardProvider
.widget('piechart', angular.extend({
title: 'Custom Piechart',
description: 'Creates custom Piechart with Google Sheets',
controller: 'piechartCtrl'
}, widget));
});
コントローラ
angular.module('adf.widget.charts')
.controller('piechartCtrl', function (chartService, $scope) {
window.onload = function() { init() };
function init() {
Tabletop.init({ key: chartService.googleSheetkey,
callback: function(data, tabletop) { console.log(data) },
simpleSheet: true })
}
});
コードを実行するのは非常に困難です。あなたは、テストプランナーまたは欠けている依存関係を提供する必要があります。私はそれのためにバグの追跡を開始することさえできませんでした。 – Gal