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()
私はそれを考え出した。これは機能します。:-)
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)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加