我有一个 JQuery 函数,如果我点击表单上的更新按钮,它就会触发。哪个有效。我打算将其更改为 Angular JS 指令。不知道该怎么做,我对 Angular JS 非常陌生。我曾尝试以 Angular JS 的方式对其进行编码,但我不确定如何像使用 JQuery 那样将整个表单数据传递给函数。这是html文件,表单.HTML:<form class="form-horizontal form-label-left input_mask" id="billingInfoForm" name="billingInfoForm"> <div class="row"> <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback"> <label class="control-label" for="firstName">First Name </label> <input type="text" data-recurly="first_name" class="form-control" id="firstName" name="firstName" ng-model="team.team_name"> </div> <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback"> <label class="control-label" for="lastName">Last Name </label> <input type="text" class="form-control" id="lastName" name="lastName" data-recurly="last_name"> </div> </div> <div class="row"> <div class="col-md-4 col-sm-4 col-xs-12 form-group has-feedback"> <label class="control-label" for="address1">Address</label> <input type="text" data-recurly="address1" class="form-control" id="address1" name="address1" ng-model="team.team_address.address1"> </div> <div class="col-md-2 col-sm-2 col-xs-12 form-group has-feedback"> <label class="control-label" for="city">City</label> <input type="text" class="form-control" id="city" name="city" data-recurly="city" ng-model="team.team_address.city"> </div> <div class="col-md-2 col-sm-2 col-xs-12 form-group has-feedback"> <label class="control-label" for="state">State <span class="required"></span></label> <input type="text" class="form-control" id="state" name="state" data-recurly="state" ng-model="team.team_address.region"> </div>
1 回答
斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
使用表单的元素,而不是字符串:
$scope.update = function(event){
//event.preventDefault();
̶v̶a̶r̶ ̶f̶o̶r̶m̶ ̶=̶ ̶'̶b̶i̶l̶l̶i̶n̶g̶I̶n̶f̶o̶F̶o̶r̶m̶'̶;̶
var formEl = document.getElementById('billingInfoForm');
var form = angular.element(formEl);
recurly.token(form, function (err, token) {
if (err) {
console.log(err);
} else {
somefunction();
form.submit();
}
});
}
添加回答
举报
0/150
提交
取消