I am writing a simple form that submits some values to a function in an angularJs controller when the form is submitted. I have done this before with no issues but there seems to be a problem with this particular piece of code as the function does not seem to be being invoked.
I have tried with 'ng-click' on an element in the scope to check the controller was being loaded correctly and this worked fine, so this seems to be an issue with 'ng-submit'.
Here is my code:
View:
<form name="briefForm" role="form" data-ng-submit="briefOneSubmit($this)" >
<!-- FIRST NAME -->
<span class="input-label padding-top"> First Name* </span>
<label class="item item-input brief-field">
<input type="text" ng-model="formData.firstName" name="firstName" required>
</label>
<span data-ng-show="briefForm.firstName.$error.required && briefForm.firstName.$dirty" class="help-block">A first name must be entered</span>
<!-- LAST NAME -->
<span class="input-label"> Last Name* </span>
<label class="item item-input brief-field">
<input type="text" data-ng-model="formData.lastName" name="lastName" required>
</label>
<span data-ng-show="briefForm.lastName.$error.required && briefForm.lastName.$dirty" class="help-block">A last name must be entered</span>
<!-- COMPANY -->
<span class="input-label"> Company* </span>
<label class="item item-input brief-field">
<input type="text" data-ng-model="formData.company" name="company" required>
</label>
<span data-ng-show="briefForm.company.$error.required && briefForm.company.$dirty" class="help-block">A company must be entered</span>
<!-- EMAIL -->
<span class="input-label"> Email Address* </span>
<label class="item item-input brief-field">
<input type="email" data-ng-model="formData.email" name="email" required>
</label>
<span data-ng-show="briefForm.email.$error.required && briefForm.email.$dirty" class="help-block">A valid email address must be entered</span>
<!-- PHONE NUMBER -->
<span class="input-label"> Phone Number </span>
<label class="item item-input brief-field">
<input type="email">
</label>
<!-- TERMS TICK BOX -->
<div class="terms-section">
<span class="terms-text"> I have read and agreed to the </br><a class="terms-link" href="#" ng-click="termsLink()"> Terms and conditions </a> </span>
</div>
<!-- SUBMIT BUTTON -->
<input type="submit" id="submit" class="button button-block button-buy" value="Get Started" />
<!-- MANDATORY LABEL -->
<p class="padding-top">* Mandatory fields</p>
</form>
Controller:
$scope.briefOneSubmit = function(form) {
console.log(form);
};
I can't seem to see why this function is not being invoked. Can anyone see why this may be occurring? Thanks
Aucun commentaire:
Enregistrer un commentaire