ng模型对象的角度问题

萨格苏里亚

由于某种原因,模型对象不会进行迭代。当我尝试循环$ scope.model时,它不起作用...当我选择几个复选框时,我需要在控制台中检查ID。.$ scope.model是动态的。默认情况下为空,但如果选中某些复选框,它将创建。

http://plnkr.co/edit/hPn01mcxjzoHGSwMZQrW?p=preview

$scope.model = {}; 

  for(var i in $scope.model){
   console.log(i);
   if($scope.model[i]== true){
   console.log("checked id is"+i);
 } 
高拉夫·巴萨(Gaurav Bhavsar)

我在html文件的输入元素中添加了ng-click(key)函数。

HTML:

<input type="checkbox" ng-model="model[key]" ng-true-value="'{{val}}'" ng-click="selectedkey(key)" ng-false-value="undefined">

JS

$scope.selectedkey = function(key){
            console.log(key);
}

这是the

单击复选框,然后检查浏览器的控制台。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章