Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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 如果Angularjs中的复选框为true,如何获取动态生成的复选框的值_Javascript_Angularjs - Fatal编程技术网

Javascript 如果Angularjs中的复选框为true,如何获取动态生成的复选框的值

Javascript 如果Angularjs中的复选框为true,如何获取动态生成的复选框的值,javascript,angularjs,Javascript,Angularjs,嗨,我正在开发angularjs应用程序。我已经使用ng repeat动态生成了复选框。我的设计如下 <ul> <li ng-repeat="screen in screenMap"> <input type="text" ng-model="screen.scrn_name" /> <input type="hidden" value="{{screen.scrn_id}}" /> <

嗨,我正在开发angularjs应用程序。我已经使用ng repeat动态生成了复选框。我的设计如下

<ul>
    <li ng-repeat="screen in screenMap">
        <input type="text" ng-model="screen.scrn_name" />
        <input type="hidden" value="{{screen.scrn_id}}" />
        <input type="checkbox" name="vehicle" value="Read">
        <input type="checkbox" name="vehicle" value="Write">
        <br>
    </li>
</ul>
<input type="button" value="APPLY" ng-click="apply()" />
我想得到像scrn_name这样的数组,true,false格式。如果选中该复选框,则为true,否则为false。 我可以知道怎么才能拿到这个吗?任何帮助都将不胜感激。谢谢。

请讲一遍

使用
ng真值
ng真值

<ul>
<li ng-repeat="screen in screenMap">
<input type="text" ng-model="screen.scrn_name" />
<input type="hidden" value="{{screen.scrn_id}}"/>
<input type="checkbox" name="vehicle" ng-model="screen.write" ng-true-value="true" ng-false-value="false"> 
<input type="checkbox" name="vehicle" ng-model="screen.read" ng-true-value="true" ng-false-value="false"><br>
</li>
</ul>
<input type="button" value="APPLY" ng-click="apply()"/>


$scope.apply = function () {
  console.log($scope.screenMap);//[{..,read:true,write:false},...]
}

$scope.apply=函数(){ console.log($scope.screenMap);//[{..,读:真,写:假,},] }
请查看angular doc,谢谢。如何循环上述文本框和复选框?创建一个对象数组来存储复选框值谢谢$scope.storechecboxvalues={};如果我没有错的话,这是正确的方法吗?实际上我试过angular.forEach(屏幕图,函数(值,键){});这给了我一个错误,屏幕图没有定义。我可以知道错误的原因吗?@niranjangodOLE应该是angular.forEach($scope.screenMap,function(value,key){});
<ul>
<li ng-repeat="screen in screenMap">
<input type="text" ng-model="screen.scrn_name" />
<input type="hidden" value="{{screen.scrn_id}}"/>
<input type="checkbox" name="vehicle" ng-model="screen.write" ng-true-value="true" ng-false-value="false"> 
<input type="checkbox" name="vehicle" ng-model="screen.read" ng-true-value="true" ng-false-value="false"><br>
</li>
</ul>
<input type="button" value="APPLY" ng-click="apply()"/>


$scope.apply = function () {
  console.log($scope.screenMap);//[{..,read:true,write:false},...]
}