2012-11-01から1日間の記事一覧

AngularJSでRailsサーバにPOSTリクエストを非同期送信する

要するに、metaタグにあるauthenticity_tokenをPOST時のパラメータで渡す必要がある。HTML中のボタンを押すとsendHoge()関数が実行されるとする。 <div ng-controller="HogeCtrl"> <button ng-click="sendHoge()">送る</botton> </div> このときsendHoge()は次のようになる。 HogeCtrl = function($scope, $http) { $scope.sendHoge = fun…