0

http post を使用してフォームを送信しようとしていますが、フォームに入力して続行ボタンを押しても何も起こりません。http 投稿は、Chrome のネットワーク タブでも発生しません。何か案は?私のコードは以下の通りです:

私の角度コントローラー:

  $routeProvider.when('/member-reg',{
    templateUrl: 'index.php/routers/member_reg',
    controller: 'registerAsMember'
  });
app.factory("memberRegistrationService", function($http, $location) {
  return {
    register: function(member_info) {
      return $http({
            method: 'POST',
            url: 'index.php/home/member_reg',
            data: { member_info: member_info }
      });
    }
  }
});

app.controller('registerAsMember', function($http, $location, $scope, memberRegistrationService) {
      $scope.member_info = { username: "", password: "",
                             firstname: "", lastname: "", email: "" };
      $scope.member_reg_submit = function() {
        memberRegistrationService.register($scope.member_info).success(function(data) {
          if(data.success == true) {
            model('hello world');
          }
        }).error(function(data) {
          alert('error');
        });
      }
 });

私の見解:

<div class="alert alert-block">
  <button type="button" class="close" data-dismiss="alert">&times;</button>
  <h4>Register as a Member ...</h4>
  Fill out the form below and press continue when finished.
</div>
<form ng-submit="member_reg_submit">
    <label>Key in your desired username below:</label>
    <input autofocus ng-model="memberinfo.username" style="width: 200pt" type="text" placeholder="Username..." required><br>
    <label>Key in your desired password:</label>
    <input ng-model="memberinfo.password" style="width: 200pt" type="password" placeholder="Password..." required><br>
    <label>Enter your firstname:</label>
    <input ng-model="memberinfo.firstname" style="width: 200pt" type="text" placeholder="Firstname..." required><br>
    <label>Type in your lastname below:</label>
    <input ng-model="memberinfo.lastname" style="width: 200pt" type="text" placeholder="Lastname..." required><br>
    <label>Your email address:</label>
    <input ng-model="memberinfo.email" style="width: 200pt" type="text" placeholder="Email..." required><br>
    <button type="submit" class="btn">Continue</button><br><br>
</form>
4

1 に答える 1

1

Continue に ng-click="member_reg_submit()" を追加

から ng-submit="member_reg_submit" を削除します

更新されたコード:

<form>
<label>Key in your desired username below:</label>
<input autofocus ng-model="memberinfo.username" style="width: 200pt" type="text" placeholder="Username..." required><br>
<label>Key in your desired password:</label>
<input ng-model="memberinfo.password" style="width: 200pt" type="password" placeholder="Password..." required><br>
<label>Enter your firstname:</label>
<input ng-model="memberinfo.firstname" style="width: 200pt" type="text" placeholder="Firstname..." required><br>
<label>Type in your lastname below:</label>
<input ng-model="memberinfo.lastname" style="width: 200pt" type="text" placeholder="Lastname..." required><br>
<label>Your email address:</label>
<input ng-model="memberinfo.email" style="width: 200pt" type="text" placeholder="Email..." required><br>
<button type="submit" class="btn" ng-click="member_reg_submit()" >Continue</button><br><br>

于 2013-09-16T07:10:12.593 に答える