如何使用Restangular保存新对象? 当我对客户对象执行save()时,我收到此错误。知道为什么吗?
saving "customer name" customers.js?body=1:14
TypeError: undefined is not a function
HTML
<form ng-submit="save(customer)">
<input type="text" ng-model="customer.name">
控制器 (coffeescript)
$scope.save = (customer) ->
console.log("saving '#{customer.name}'") # this works
customer.save()
答案 0 :(得分:0)
我明白了。这有效。 : - )
1 angular
2 .module('app')
3 .controller "CustomersCtrl", ($scope, Restangular) ->
4
5 # Initalize the Customer object
6 Customer = Restangular.all('customers');
7
8 $scope.getCustomers = () ->
9 Customer.getList().then (customers) ->
10 $scope.customers = customers
11
12 $scope.save = (customer) ->
13 Customer.post(customer)