简体   繁体   English

Angular.js ng-show无法与在JSP中使用默认值为true的复选框一起使用

[英]Angularjs ng-show not working with checkbox with default value true in jsp

             <tr> 
             <td><input type="checkbox" ng-model="<%=cat4%>" ng-checked="true"> </td>
            <td>
            <%=cat2%>
             </td>
             <td><input type="text" class="txt" ng-show="<%=cat4%>" placeholder="Enter Price per <%=cat2%>" value="<%=temps[i]%>"></td>    
            </tr>

I want to display the text box when checkbox is checked. 我想在选中复选框时显示文本框。 The checkbox is by default checked. 默认情况下,该复选框处于选中状态。 When the check box is unchecked then the text box should be hidden. 如果未选中该复选框,则应隐藏该文本框。 Using the above code the checkbox is checked but the textbox is not displayed (when the form loads). 使用上面的代码,复选框已选中,但未显示文本框(加载表单时)。 When I uncheck and again check the checkbox then only the text box is displayed. 当我取消选中并再次选中复选框时,仅显示文本框。 What changes are needed in the code? 代码需要进行哪些更改?

unchecking it doesn't make it false 取消选中它不会使它错误

use ng-change to turn it for false to true and vice versa 使用ng-change将其从false变为true,反之亦然

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM