1

How send variables year, monthGet function angular service from controller?

Service

myApp.factory('getJsonForCalendarService', function($resource, year, monthGet) {

        return $resource(
            '../rest/api.php',
            { method: 'getJsonForCalendar', year: year, monthGet:month},
            {'query': { method: 'GET', isArray: true }}
        );

});

Controller

$scope.getJsonForCalendar = getJsonForCalendarService.query(function (response, year, monthGet) {
});

1 Answer 1

2

Your factory function is only ever instantiated (called/newed) once by the applications injector: You need to do this:

myApp.factory('getJsonForCalendarService',function($resource){
    return function(year,month){        
        return $resource(
            '../rest/api.php',
            { method: 'getJsonForCalendar', year: year, monthGet:month},
            {'query': { method: 'GET', isArray: true }}
        );    
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.