Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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
Angularjs 如何在ng repeat下获得ng模型的值 {{prod.c}{{prod.cid}_Angularjs_Angularjs Ng Repeat_Ng Bind - Fatal编程技术网

Angularjs 如何在ng repeat下获得ng模型的值 {{prod.c}{{prod.cid}

Angularjs 如何在ng repeat下获得ng模型的值 {{prod.c}{{prod.cid},angularjs,angularjs-ng-repeat,ng-bind,Angularjs,Angularjs Ng Repeat,Ng Bind,在上面的html文件中,我从函数a()的控件中动态地获取了复选框。现在我需要在函数OnCheck()的控件中获取该复选框的绑定值。如何在另一个函数名(如OnCheck()中)中获取绑定值也在同一个控件中。我还有其他非动态的复选框,我正在使用OnCheck()ng更改所有复选框。HTML: <div class="check"> <label><span ng-repeat="prod in products"> <input type="checkbox

在上面的html文件中,我从函数
a()
的控件中动态地获取了复选框。现在我需要在函数
OnCheck()
的控件中获取该复选框的绑定值。如何在另一个函数名(如
OnCheck()中)中获取绑定值
也在同一个控件中。我还有其他非动态的复选框,我正在使用
OnCheck()
ng更改所有复选框。

HTML:

<div class="check">
<label><span ng-repeat="prod in products">
<input type="checkbox" ng-model="prod.cid"  value="" ng-change="OnCheck()">
{{prod.c}}</br></br>{{prod.cid}}</br>
</span>
</div>
//您可以通过产品访问 ...

HTML:


对于动态创建的复选框

    $scope.OnCheck = function(cid)
// in this case you can have access to prod.cid only
    ... 

但我还有剩余的复选框,它们在html页面中不是动态的,也可以使用OnCheck()方法。如何将所有复选框操作处理为一个函数。请更新您的问题,以显示其外观如何?如何获取第一个答案的所有复选框的cid对于您的第一个答案,它在警报中显示对象,在控制台中显示true,但不显示实际值。对象结构为{cid=true,cat=“B”,$$hashKey=“00A”},我怎样才能得到什么cid的实际值?product.cid对于您的回答,它在警报中显示对象,在控制台中显示true,但不是实际值。对象结构是{cid=true,cat=“B”,“$$hashKey=“00A”}。我怎样才能得到实际值
...
$scope.OnCheck = function(product)
   <div class="check">
    <label><span ng-repeat="prod in products">
    <input type="checkbox" ng-model="prod.cid"  value="" ng-change="OnCheck(prod.cid)">
    {{prod.c}}</br></br>{{prod.cid}}</br>
    </span>
    </div>
    $scope.OnCheck = function(cid)
// in this case you can have access to prod.cid only
    ... 
<input type="checkbox" ng-model="prod.cid" ng-change="OnCheck(prod.cid)">
<input type="checkbox" ng-change="OnCheck('value')">
          //Give the value of checkbox between the quotes ''.
$scope.OnCheck = function(Value){
   console.log(Value);
}