0

我被一个问题吞噬了。

我目前有这个代码

<div ng-repeat="list in ConnectivityDetails">
            <div class="connectivity">
                <div class="title">
                    Disable Connectivity??</div>
                <div class="decision">
                    <p style="float: left;">
                        <input type="checkbox" ng-checked="list.Connectivity"/>
                        <label for="Yes">
                        </label>
                        &nbsp;&nbsp;<span class="spans">Yes</span>
                    </p>
                    <p>
                        <input type="checkbox" ng-model="list.Connectivity"/>
                        <label for="No">
                        </label>
                        &nbsp;&nbsp;<span class="spans">No</span>
                    </p>
                </div>
            </div>
</div>

问题: 虽然返回的对象只有一个值,但我得到了两个文本框,如何为复选框绑定(是)和为另一个绑定(否)?checkedtruefalse

我的对象包含这个:

var data = [{PracticeID: "1",Connectivity: "true", LabKey: "2154879",PracticeKey: "ABNCJFUE", CloudServiceURL: "ABC215947"}]";

我想将Connectivity值绑定到其中一个复选框

帮助!谢谢

4

1 回答 1

1

小提琴:http: //jsfiddle.net/ymZdx/3/

所以应该是:

           <p style="float: left;">
                <input type="checkbox" ng-model="list.Connectivity" />
                <label for="Yes">
                </label>
                &nbsp;&nbsp;<span class="spans">Yes</span>
            </p>
            <p>
                <input type="checkbox" ng-model="list.Connectivity" ng-true-value="false" ng-false-value="true" />
                <label for="No">
                </label>
                &nbsp;&nbsp;<span class="spans">No</span>
            </p>
于 2013-06-19T17:09:16.880 回答