我使用NG提交按钮尝试将提交数据的点击事件绑定到角度变量并遇到问题。
角度代码:
formApp.controller('formController', function ($scope) {
// we will store all of our form data in this object
// function to process the form
$scope.processForm = function () {
var fn = $scope.firstname;
alert('your reccommendation has been submitted!' + fn);
};
NG-submit位于html中
<form id="signup-form" ng-submit="processForm()">
<!-- our nested state views will be injected here -->
<div id="form-views" ui-view></div>
</form>
填写名字数据的地方是:
<strong>First Name:</strong>
<input name="FirstName" size='16' ng-model="firstname" />
<br />
<br />
现在,在您说NG-submit不在我的表单附近之前,表单视图与初始表单相关联。当您按提交时警报工作正常,但变量返回未定义。任何帮助都会有所帮助!