1
我正在研究angularjs google的柱形图。我的要求是将一个javascript函数的值分配给其他javascript函数中定义的另一个变量。对于myController.js在javascript文件中将一个函数的值赋值给另一个函数
var globalID;
app.controller('myChart',['$rootScope','$scope','$uibModal','myService',function($rootScope,$scope,$uibModal,myService) {
$scope.chart = {};
$scope.chart.options = {
"title": "Summary API Tests",
'fontSize': '12',
"isStacked": "true",
colors: ['blue', 'cyan', 'red'],
axisFontSize : 8,
};
$scope.chart.type = "ColumnChart";
$scope.function2= function(event) {
alert('in function2');
/* want to assign the value of val from below lines to globalID */
/* globalID = val; */
};
/* I want to invoke below lines in $scope.chartClick*/
$scope.function1= function (selectedItem) {
$scope.chart.data.rows[selectedItem.row].c[0].v;
val = $scope.chart.data.rows[selectedItem.row].c[0].v;
alert("inside function1: " + val);
};
//some more logic below
});
在上述js文件
示例代码片段,我想val的从$ scope.function1值分配给内部函数2 globalID。