Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 两个文本框之间的ng模型应基于复选框输入_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 两个文本框之间的ng模型应基于复选框输入

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"/&

我正在构建一个UI页面,表单由2个文本框和一个复选框组成,如果复选框为true,则两个文本框的内容应立即相互更新

代码示例


将两个密码的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
}