I'm having trouble on figuring out how to pass parameters from my angular
controller
to
service
#my controller
'use strict';
angular.module('recipeapp')
.controller('recipeCtrl', ['$scope', 'recipeService',
function($scope, recipeService){
$scope.recipeFormData={};
$scope.recipeSave = function(){
recipeService.saveRecipe();
}
}]);
#my service
'use strict';
angular.module('recipeapp').service('recipeService',['$http', function($http){
this.saveRecipe = save;
function save(callback){
//calling external http api
}
}]);
What I'm trying to do here is , getting the $scope.formData
from my form and controller should pass that to service
, As per my understanding, I cannot use $scope
inside the service
so I need to find a way of passing $scope.formData
to the service
tough Idea would be, in the controller, recipeService.saveRecipe($scope.formData);
but I'm not sure how to collect that from the service,
when I changed the service this.saveRecipe(val) = save;
it doesnt work :(
any help would be appriciated