问题
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.
来源:https://stackoverflow.com/questions/24326384/angularjs-edit-scope-with-same-name-from-another-method