答案 0 :(得分:1)
最简单的方法是在复选框上添加一个手表,然后将备用电子邮件设置为电子邮件地址。
$scope.formFields = [
{
"key": "firstName",
"type": "text",
"label": "First Name",
"placeholder": "Jane",
"required":true
},{
"key": "email",
"type": "email",
"label" :"Primary Email",
"placeholder": "janedoe@gmail.com",
"required":true
},
{
"key": "altEmail", // you need a unique key for this one
"type": "email",
"label":"Alternate Email",
"placeholder": "janedoe@gmail.com",
"required":true,
ngModelAttrs: {
myCustomValue: {
bound: 'email',
attribute: 'email'
}
},
templateOptions: {
myCustomValue: "email"
}
},
// ...
$scope.$watch('result.sameAsPrimary', function(newValue) {
if (newValue) {
$scope.result.altEmail = $scope.result.email;
}
});