我正在使用angularjs google柱形图。我的要求是将一个javascript函数的值赋给其他javascript函数中定义的另一个变量。
myController.js的示例代码段
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文件中,我想将$ scope.function1中的val值赋给function2中的globalID。
答案 0 :(得分:1)
在范围
中设置值{{1}}