При вызове серверной части (GET / app / getNames) возвращается массив json.
Проблема в том, что $ scope.names в app.controller. js всегда остается пустым массив.
app.controller. js:
myApp.controller('myAppController', ['$scope','$http','myAppService',
function($scope, $http, myAppService) {
$scope.names = [];
myAppService.getNames(function(response) {
$scope.names = response;
});
}
]);
app.service. js
myApp.service('myAppService', ['$http', function($http) {
this.getNames= function() {
return $http({
method: 'GET',
url: '/app/getNames',
});
}
}]);