我有一个带有文本框和复选框的表单。复选框是互斥的。我想在单击“提交”按钮时传递所选值。只有电子邮件值正在获取且复选框值未获取。我是Angular JS的新手。请帮忙解决这个问题。这就是我试过的
<ng-form name="manageForm">
<md-input-container class="md-block">
<label>E-mail</label>
<input required md-asterisk name="email" ng-model="manage.model.email">
</md-input-container>
<div ng-repeat="designation in $manageController.designations">
<md-checkbox ng-model="designation.checked" ng-change="$manageController.change(designation)">
{{ designation.name }}
</md-checkbox>
</div>
<div>
<md-button class="md-raised md-primary bm-button" ng-disabled="manageUsersForm.$invalid || manageUsersForm.$pristine" ng-click= "$manageController.submitUser(manage.email,designation.checked)">Submit</md-button>
</div>
控制器功能
this.submitUser = function (email, designation) {
console.log(email, designation)
}
答案 0 :(得分:0)
更改您实施的方式复选框 使用ng-checked代替ng-model
<div ng-repeat="designation in $manageController.designations">
<md-checkbox ng-checked="designation.checked" ng-change="$manageController.change(designation)">
{{ designation.name }}
</md-checkbox>