i using play framework angular with configuration like this :
where is my data from test.json file gone ?
app.js
>
> require(['angular', './controllers', './directives', './filters',
> './services', 'angular-route','angular-resource'],
> function(angular, controllers) {
> angular.module('myApp', ['ngRoute','myApp.filters',
> 'myApp.services', 'myApp.directives']).
> config(['$routeProvider', function($routeProvider) {
> $routeProvider.when('/report', {templateUrl:
> 'partials/report/list.html', controller: controllers.ReportListController});
> $routeProvider.when('/report/create', {templateUrl:
> 'partials/report/create.html', controller:
> controllers.ReportCreateController});
> $routeProvider.otherwise({redirectTo: '/view1'});
> }]);
> angular.bootstrap(document, ['myApp']);
> });
>
controller.coffee
'use strict'
>
> define () ->
>
> controllers = {};
>
> #Report Controller
>
> controllers.ReportListController = ($scope,ReportService) ->
>
> $scope.title = "Report List"
>
> $scope.reports = ReportService;
>
> $scope.print = ()->
>
> console.log(this.reports.query)
>
> controllers.ReportListController.$inject = ['$scope','ReportService']
>
>
>> controllers.ReportCreateController = ($scope) ->
>
> $scope.title = "Create New Report"
>
> controllers.ReportCreateController.$inject = ['$scope']
>
> controllers
>
>
and my factory :
'use strict';
define(['angular'], function (angular) {
var services = angular.module('myApp.services', ['ngResource']);
services.factory('ReportService', function ($resource) {
var fac = $resource('/test.json', {}, {
query: { method: 'GET', isArray: true },
create: { method: 'POST' }
})
return fac;
});
});
but every i call the ReportService.query from controller and print it no
data found but just this message, please help me :( :
> function (a1, a2, a3, a4) { var params = {}, data, success, error; /*
> jshint -W086 */ /* (purposefully fall through case statements) */
> switch(arguments.length) { case 4: error = a4; success = a3; //fallthrough
> case 3: case 2: if (isFunction(a2)) { if (isFunction(a1)) { success = a1;
> error = a2; break; } success = a2; error = a3; //fallthrough } else {
> params = a1; data = a2; success = a3; break; } case 1: if (isFunction(a1))
> success = a1; else if (hasBody) data = a1; else params = a1; break; case 0:
> break; default: throw $resourceMinErr('badargs', "Expected up to 4
> arguments [params, data, success, error], got {0} arguments",
> arguments.length); } /* jshint +W086 */ /* (purposefully fall through case
> statements) */ var isInstanceCall = this instanceof Resource; var value =
> isInstanceCall ? data : (action.isArray ? [] : new Resource(data)); var
> httpConfig = {}; var responseInterceptor = action.interceptor &&
> action.interceptor.response || defaultResponseInterceptor; var
> responseErrorInterceptor = action.interceptor &&
> action.interceptor.responseError || undefined; forEach(action,
> function(value, key) { if (key != 'params' && key != 'isArray' && key !=
> 'interceptor') { httpConfig[key] = copy(value); } }); if (hasBody)
> httpConfig.data = data; route.setUrlParams(httpConfig, extend({},
> extractParams(data, action.params || {}), params), action.url); var promise
> = $http(httpConfig).then(function(response) { var data = response.data,
> promise = value.$promise; if (data) { // Need to convert action.isArray to
> boolean in case it is undefined // jshint -W018 if (angular.isArray(data)
> !== (!!action.isArray)) { throw $resourceMinErr('badcfg', 'Error in
> resource configuration. Expected ' + 'response to contain an {0} but got an
> {1}', action.isArray?'array':'object',
> angular.isArray(data)?'array':'object'); } // jshint +W018 if
> (action.isArray) { value.length = 0; forEach(data, function(item) {
> value.push(new Resource(item)); }); } else { shallowClearAndCopy(data,
> value); value.$promise = promise; } } value.$resolved = true;
> response.resource = value; return response; }, function(response) {
> value.$resolved = true; (error||noop)(response); return
> $q.reject(response); }); promise = promise.then( function(response) { var
> value = responseInterceptor(response); (success||noop)(value,
> response.headers); return value; }, responseErrorInterceptor); if
> (!isInstanceCall) { // we are creating instance / collection // - set the
> initial promise // - return the instance / collection value.$promise =
> promise; value.$resolved = false; return value; } // instance call return
> promise; } controllers.js:11 <http://localhost:9000/js/controllers.js>
> function (a1, a2, a3, a4) { var params = {}, data, success, error; /*
> jshint -W086 */ /* (purposefully fall through case statements) */
> switch(arguments.length) { case 4: error = a4; success = a3; //fallthrough
> case 3: case 2: if (isFunction(a2)) { if (isFunction(a1)) { success = a1;
> error = a2; break; } success = a2; error = a3; //fallthrough } else {
> params = a1; data = a2; success = a3; break; } case 1: if (isFunction(a1))
> success = a1; else if (hasBody) data = a1; else params = a1; break; case 0:
> break; default: throw $resourceMinErr('badargs', "Expected up to 4
> arguments [params, data, success, error], got {0} arguments",
> arguments.length); } /* jshint +W086 */ /* (purposefully fall through case
> statements) */ var isInstanceCall = this instanceof Resource; var value =
> isInstanceCall ? data : (action.isArray ? [] : new Resource(data)); var
> httpConfig = {}; var responseInterceptor = action.interceptor &&
> action.interceptor.response || defaultResponseInterceptor; var
> responseErrorInterceptor = action.interceptor &&
> action.interceptor.responseError || undefined; forEach(action,
> function(value, key) { if (key != 'params' && key != 'isArray' && key !=
> 'interceptor') { httpConfig[key] = copy(value); } }); if (hasBody)
> httpConfig.data = data; route.setUrlParams(httpConfig, extend({},
> extractParams(data, action.params || {}), params), action.url); var promise
> = $http(httpConfig).then(function(response) { var data = response.data,
> promise = value.$promise; if (data) { // Need to convert action.isArray to
> boolean in case it is undefined // jshint -W018 if (angular.isArray(data)
> !== (!!action.isArray)) { throw $resourceMinErr('badcfg', 'Error in
> resource configuration. Expected ' + 'response to contain an {0} but got an
> {1}', action.isArray?'array':'object',
> angular.isArray(data)?'array':'object'); } // jshint +W018 if
> (action.isArray) { value.length = 0; forEach(data, function(item) {
> value.push(new Resource(item)); }); } else { shallowClearAndCopy(data,
> value); value.$promise = promise; } } value.$resolved = true;
> response.resource = value; return response; }, function(response) {
> value.$resolved = true; (error||noop)(response); return
> $q.reject(response); }); promise = promise.then( function(response) { var
> value = responseInterceptor(response); (success||noop)(value,
> response.headers); return value; }, responseErrorInterceptor); if
> (!isInstanceCall) { // we are creating instance / collection // - set the
> initial promise // - return the instance / collection value.$promise =
> promise; value.$resolved = false; return value; } // instance call return
> promise; }
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.