Get json data file for angular js app-in-app in grails directly

Hi i want to access my json data file in my angular app inside my app in grails. I cannot find a way to access the client json file. in the tutorial, data binding is only for json data, so this matters to me.

function ShitCtrl($scope, $http) {

  $http.get('http://localhost:8080/webapp/clients.json').success(function(data) {
    $scope.shits = data;
  });
}


function ShitDetailCtrl($scope, $routeParams) {
  $scope.shitId = $routeParams.shitId;

}

      

this reports a 404 error. how can i solve this problem? when i access it in urlMappings it doesn't work then the mappings are absolute.

dot: grails renders everything based on urlMappings so it is not possible to access the file directly from js.

+3


source to share


1 answer


config. groovy:

grails.resources.adhoc.patterns = [
        '/images/*',
        '/css/*',
        '/js/*',
        '/plugins/*',
        **'/staticData/*',**
        '/assets/*'

      



so this works like a charm:

function ShitCtrl($scope, $http) {
  $http.get('../static/staticData/clients.json').success(function(data) {
    $scope.shits = data;
  });
}

      

+1


source







All Articles