我想在同一类的另一个方法中用同名更新范围内的某些值。
问题是如果我正在尝试更新名为 gridData 的范围,则更新方法无效。
我应该在Angular中使用范围应用还是Simillar?
这是我的代码:
orders.controller('OrdersCtrl', function ($scope, $http, $rootScope, $location, $notification, $routeParams, ApiService) {
$scope.gridData = {};
$scope.initGrid = function () {
$scope.gridData = new kendo.data.ObservableArray([
{ artist: "Pink Floyd", track: "The dark side of the Moon" },
{ artist: "The Beatles", track: "I've just seen a face" },
{ artist: "Queen", track: "Innuendo" }
]);
$scope.test = function() {
console.log('dede');
};
$scope.data.test,$scope.gridColumns = [
{ field: "artist", title: "Artist" },
{ field: "track", title: "Track" }
];
};
$scope.update = function() {
// empty JSON object
console.log($scope.gridData);
// Here i get error
$scope.gridData[0].set("track", "Hey you");
};
感谢任何有关如何正确执行此操作的示例。