http://jsfiddle.net/ADukg/2644/
为什么我在每个过滤器中的默认值“已检查”没有在页面加载的复选框中设置?
我正在使用batarang对其进行调试,当我单击复选框时,它看起来模型正在更新,但是'checked'的默认值是真的看起来不像它被应用了。
如果我使用 ng-checked="filter.checked" 似乎确实有效,但我不知道为什么。
JavaScript:
$scope.filtersList = [
{"name":"type","checked":"true","label":"Source(s)","CSSClasses":"",
"values":[
{"key":"Online News","value":1,"parent":"false","children":[],"checked":"true"},
{"key":"Twitter","value":15,"parent":"false","children":[],"checked":"true"}]
},
HTML:
<div class="filter-listing" ng-controller="sidebar">
<ul class="filterSection" ng-repeat="filter in filtersList">
<li class="clearfix">
<span class="pull-left">
<a class="pull-left twistdown filterToggle"
href="#" title="Expand" data-toggle="collapse"
style="margin-top: 6px">
<i class="icon-white icon-plus-sign"></i>
</a>
<input type="checkbox" ng-model="filter.checked" id="filter.name" class="parentCheckbox allFilterCheckbox"/>
<label
style="display: inline;" for="filter.name">
{{filter.label}}
</label>