I need to update view when new data created at server? How to do this correct?
My controller
app.controller('MainController', ['$scope', 'games', function($scope, games) {
games.success(function(data) {
console.log(data[0]);
$scope.games = data[0];
});
}]);
My factory
app.factory('games', ['$http', function($http) {
return $http.get('./game')
.success(function(data) {
return data;
})
.error(function(data) {
return data;
});
}]);