我正在尝试在网格中绑定$ scope.span00,span01,span10等。
$scope.span01 = 'test'; // this works fine
现在为ng-click ...
$scope.clickedOn = function(row, column) {
var gridLocation = function() { return 'span'.concat(row).concat(column); } // returns span01
$scope.gridLocation() = 'test'; // says $scope.gridLocation() is not a function.
}
它说这不是一个功能。我该怎么办?
答案 0 :(得分:2)
因为$scope
上不存在该功能。这是你需要做的:
$scope.gridLocation = function (row, column) {
return 'span'.concat(row).concat(column);
};
$scope.clickedOn = function (row, column) {
$scope.gridLocation(row, column);
};
修改强>
在评论中做你要求的事情(我希望我理解正确):
$scope.clickedOn = function (row, column) {
$scope[$scope.gridLocation(row, column)] = 'test';
};