I want to send the data in my controller to the database via service, but I use a $resource in a service and I don't know how to call it from the controller, below is my controller,
angular.module('dashboard').controller('DashboardCtrl',['dashboardResource',DashboardCtrl]);
function DashboardCtrl(dashboardResource){
var vm = this;
vm.payments = [
{
"paymentId":1,
"date":"2015/09/13 12.36PM",
"name":"HSBC Bank",
"ID": 123456,
"amount": 1000.00,
"status": "Active"
}]
vm.payments = dashboardResource.get({name: vm.payments.name}, function(payments) {
payments = vm.payments();
});
}
Below is my service
angular.module('lgpsService').factory('dashboardResource',[
"$resource",dashboardResource]);
function dashboardResource($resource) {
return $resource('api/Payment/makePayment');
}
Please help me to resolve this issue.