【发布时间】:2016-01-08 16:08:35
【问题描述】:
我正在使用 Angular 构建一个小部件,它采用用户提供的 Google 工作表 ID,并以漂亮的 json 格式发布输出。问题是我的代码什么都不做。控制台中没有错误,当我添加 ID 时没有任何反应
我猜问题出在 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 } )
}
});
【问题讨论】:
-
在您的代码中工作非常困难。您应该提供一个 Testing Plunker 或缺少的依赖项。因此,我什至无法开始跟踪您的错误。
标签: javascript angularjs google-sheets tabletop.js