我正在尝试构建一个联系表单应用程序,目前我仍然无法执行我的控制器中定义的范围函数。除了console.log之外,我目前没有任何东西被这个功能执行,而单独这个功能无效。我知道这个问题不是源于文件没有被正确包含。</ p>
这是app.js:
var app = angular.module('contactFormApp', ['xtForm']);
app.controller('contactFormController', function($scope) {
$scope.formSubmit = function() {
console.log('success');
}
});
我试图将其链接到视图中,如下所示:
<div ng-controller="contactFormController">
<form name="contactForm" xt-form role="form" focus-error="true"
novalidate>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<div class="col-xs-2">
<label for="firstName">First Name:</label>
</div>
<div class="col-xs-4">
<input type="text"
class="form-control name in-block"
ng-model="contactForm.firstName"
id="firstName"
autocomplete="off"
placeholder="First"
xt-validation-tooltip
required
msg-required="Please enter your first name.">
</div>
</div>
并且(跳过大部分表格)视图的底部写成如下:
<button type="submit" class="btn btn-lg" ng-click="formSumbit()">Submit</button>
</form>
</div>