我想通过服务将控制器中的数据发送到数据库,但是我在服务中使用了 $resource 并且我不知道如何从控制器调用它,下面是我的控制器,
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();
});
}
以下是我的服务
angular.module('lgpsService').factory('dashboardResource',[
"$resource",dashboardResource]);
function dashboardResource($resource) {
return $resource('api/Payment/makePayment');
}
请帮我解决这个问题。