I would like to update some value in scope with same name in another method of same class.
Problem is that update method is not working if i'm trying to update scope named gridData.
Should i use scope apply or something Simillar in Angular?
Here is my code:
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");
};
Thanks for any example how to do it correctly.
$scope.gridData
is an empty object,$scope.gridData[0]
will of course be undefined, so it will throw an error. – dirkk Jun 20 at 11:41