Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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 角度复选框未更新为视图中的已选中_Angularjs_Google Chrome_Checkbox_Angularjs Directive - Fatal编程技术网

Angularjs 角度复选框未更新为视图中的已选中

Angularjs 角度复选框未更新为视图中的已选中,angularjs,google-chrome,checkbox,angularjs-directive,Angularjs,Google Chrome,Checkbox,Angularjs Directive,我用的是铬 这是我的html代码 ng-repeat="tag in formData.amenities"><label><input type="checkbox" ng-model="tag.enabled">{{tag.text}}:{{tag.enabled}} ng repeat=“formData.professionals中的标记”>{{tag.text}:{{{tag.enabled} 当我从视图中选中/取消选中时,我能够收集标记值。问题在于

我用的是铬

这是我的html代码

ng-repeat="tag in formData.amenities"><label><input type="checkbox"  ng-model="tag.enabled">{{tag.text}}:{{tag.enabled}}
ng repeat=“formData.professionals中的标记”>{{tag.text}:{{{tag.enabled}
当我从视图中选中/取消选中时,我能够收集标记值。问题在于反向绑定

我读回这些值,然后应用到上面的代码中。我可以看到tag.enabled被设置为true,但是视图没有显示checked

我尝试了
$scope.apply
,但即使这样也无法更新视图。

使用
ng checked
指令

<body ng-controller="MainController">

  <div ng-repeat="tag in formData.amenities">
    <label>Checkbox: <input type="checkbox" ng-checked="tag.enabled" ng-model="tag.enabled">{{tag.text}}:{{tag.enabled}}
    </label>
    </div>

</body>

ng checked=“tag.enabled”
放在你的HTMLIt的工作模式中,好的不起作用。如果我添加了ng checked,所有内容都将被选中,即使它启用为false。请检查演示,你会得到分数。也相应地构造对象
angular.module("app", [])
    .controller("MainController", function ($scope) {
    $scope.formData = {
        amenities: [{
            "text": "First",
             "enabled": true
        }, {
            "text": "second",
            "enabled": false
        }, {
            "text": "Thid",
            "enabled": true
        }]
    };
});