Javascript 两个文本框之间的ng模型应基于复选框输入
我正在构建一个UI页面,表单由2个文本框和一个复选框组成,如果复选框为true,则两个文本框的内容应立即相互更新 代码示例Javascript 两个文本框之间的ng模型应基于复选框输入,javascript,html,angularjs,Javascript,Html,Angularjs,我正在构建一个UI页面,表单由2个文本框和一个复选框组成,如果复选框为true,则两个文本框的内容应立即相互更新 代码示例 将两个密码的ng型号保持为以下代码中的不同。使用复选框值如果为true,则可以将moodle密码值指定给fcfs密码,如 Registration number : <input type="text" ng-model="regno"/> Moodle Password : <input type="text" ng-model="modpass"/&
将两个密码的ng型号保持为以下代码中的不同。使用复选框值如果为true,则可以将moodle密码值指定给fcfs密码,如
Registration number : <input type="text" ng-model="regno"/>
Moodle Password : <input type="text" ng-model="modpass"/>
Ffcs Password : <input type="text" ng-model="fcfs"/>
Same password for both : <input type="checkbox" ng-model="chkbox"/>
if($scope.chkbox){
$scope.fcfs = $scope.modpass
}
或者您可以在Moodle密码模型上使用$watch。请分享您的代码。您可以解释更多吗?或者你可以在这里提供你的代码。太棒了,去构建它吧。如果遇到问题,请回来。
Registration number : <input type="text" ng-model="regno"/>
Moodle Password : <input type="text" ng-model="modpass"/>
Ffcs Password : <input type="text" ng-model="fcfs"/>
Same password for both : <input type="checkbox" ng-model="chkbox"/>
if($scope.chkbox){
$scope.fcfs = $scope.modpass
}