Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.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
Javascript 当条件满足时,角度表禁用切换_Javascript_Angularjs - Fatal编程技术网

Javascript 当条件满足时,角度表禁用切换

Javascript 当条件满足时,角度表禁用切换,javascript,angularjs,Javascript,Angularjs,我有一个angular应用程序,其中我定义了一个表,如下所示: <tr ng-repeat="child in requirements"> {% verbatim %} <td class="vcenter"><input type="checkbox" ng-checked="selectedCourses.indexOf(child) != -1" ng-click="toggleCheck(child)" ng-disabled="requi

我有一个angular应用程序,其中我定义了一个表,如下所示:

<tr ng-repeat="child in requirements">
    {% verbatim %}
    <td class="vcenter"><input type="checkbox" ng-checked="selectedCourses.indexOf(child) != -1" ng-click="toggleCheck(child)" ng-disabled="required == (planned + completed)" value=""/>
        {{child.course.subject}}-{{child.course.course_no}}
    </td>
    <td class="vcenter">{{child.course.course_name}}</td>
    {% endverbatim %}
    <td class="vcenter">3</td> 
</tr>

到目前为止,一切都很好,一旦满足条件,表将禁用切换。但是表禁用时,即使选中的开关也会禁用,这是有意义的。如何确保禁用仅发生在未选中的切换上,而不是发生在已选中的切换上

您还需要检查所检查的ng是否为真

<td class="vcenter">
    <input type="checkbox"
        ng-checked="selectedCourses.indexOf(child) != -1"
        ng-click="toggleCheck(child)"
        ng-disabled="required == (planned + completed) && selectedCourses.indexOf(child) == -1"
        value=""
    />
/>

/>
仅当满足上一个条件且未选中时,才会禁用

<td class="vcenter">
    <input type="checkbox"
        ng-checked="selectedCourses.indexOf(child) != -1"
        ng-click="toggleCheck(child)"
        ng-disabled="required == (planned + completed) && selectedCourses.indexOf(child) == -1"
        value=""
    />
/>