Reputation: 2247
I have a form :
<div class="col-xs-12 col-sm-6" ng-controller="registerController">
<form id="registerForm" name="registerForm" style="box-shadow: rgba(0, 0, 0, 0.17) 0px 5px 13px; margin:25px; direction:rtl" class="contact-form-box" novalidate>
<div class="account_creation">
<h3 class="page-subheading">Your personal information</h3>
<div class="required form-group">
<label class="control-label col-sm-4" for="email">Email </label>
<div class="col-sm-6 form-ok">
<input class="form-control" type="text" id="Email" name="Email" ng-model="model.Email" value="" />
</div>
</div>
<div class="required password form-group">
<label class="control-label col-sm-4" for="passwd">Password </label>
<div class="col-sm-6 form-error">
@*<input class="form-control" type="password" id="Password" name="Password" ng-model="model.Password" value="" />*@
<input class="form-control" type="password" id="Password" name="Password" ng-model="model.Password" value="" required />
<span class="form_info">(Five characters minimum)</span>
</div>
</div>
</div>
<div class="submit clearfix">
<button type="submit" name="submitAccount" id="submitAccount" class="btn btn-outline button button-medium" ng-click="register()">
<span>register</span>
</button>
<label style="color:#808080;font-size:16px" ng-if="message" ng-model="message">{{message}}</label>
</div>
</form>
</div>
and in script i have :
<script>
app.cp.register('registerController', function ($http, $scope) {
$scope.register = function () {
$scope.model = {};
$scope.model.Email = $scope.Email == undefined ? "" : $scope.Email;
$scope.model.Password = $scope.Password == undefined ? "" : $scope.Password;
debugger;
$http.post("/Account/Register", $scope.model).success(function (response) {
$scope.message = response;
});
}
});
</script>
I want post some value to a method in controller, but when i write some thing in both of inputs Email
and Password
, i got $scope.Email
and $scope.Password
undefined in regiterController
(instead of what i wrote before in the inputs) !!! what is the problem?
Upvotes: 0
Views: 57
Reputation: 3101
You are assigning to $scope.model.Email
instead of $scope.Email
and the same for the password field.
Also, you shouldn't be assigning to the model inside your register
function, you'll override the $scope.model
every time you submit.
Upvotes: 2