1

我在 ng-repeat 中有多列数据呈现,当我单击某个项目表单列时,会显示另一个,但是当我单击最后一列中的特定项目时,我想显示一个表单,我尝试使用 ng-如果要在错误的列中净呈现表单,但是当呈现最后一列并且我按下项目表单时,不仅在最后一个列上出现在所有列上

这是我的代码:

<div class="span4 menu-board" data-ng-repeat="menu in $parent.MENU">
                <ul class="nav nav-tabs nav-stacked">


                    <li data-ng-if="last_admin_code == 'CWR Acknowledgement Transaction Status'">
                        <!--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
                        <div class="editor span8" id="RECORD">
                            <button type="button" class="btn btn-mini btn-toggle">
                                <i class="icon-pencil"></i>
                            </button>
                            <div class="DETAIL">
                                <div class="row span8 display">
                                    <div class="span3 control-label"><p>Status Name:</p></div>
                                    <div class="span5"><b><span>Accepted with Changes</span></b></div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="row span8 display">
                                    <div class="span3 control-label"><p>Status Code:</p></div>
                                    <div class="span5"><b><span>AC</span></b></div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="row span8 display">
                                    <div class="span3 control-label"><p>Status Description:</p></div>
                                    <div class="span5"><b><span>&nbsp;</span></b></div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="row span8 display">
                                    <div class="span3 control-label"><p>Acknowledgement Category:</p></div>
                                    <div class="span5"><b><span>Accepted</span></b></div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="clearfix"></div>
                            </div>
                            <div class="FORM">
                                <form action="#" method="POST" class="form-horizontal" id="form2" onsubmit="return false;">
                                <fieldset id="fieldset1">
                                    <div class="control-group">
                                        <label class="control-label">Status Name:</label>
                                        <div class="span3 controls">
                                            <input class="span3" type="text" novalidate="" value="Accepted with Changes" />
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">Status Code:</label>
                                        <div class="span3 controls">
                                            <input class="span3" type="text" novalidate="" value="AC" />
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">Status Description:</label>
                                        <div class="span3 controls">
                                            <textarea class="span3"></textarea>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">Acknowledgement Category:</label>
                                        <div class="span3 controls">
                                            <select class="span3" novalidate="">
                                                <option>Accepted</option>
                                                <option>Rejeted</option>
                                                <option>Other</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="clearfix" style="margin-bottom: 20px;"></div>

                                    <div class="">
                                        <button class="btn btn-primary pull-right">Save</button>
                                        <button class="btn btn-danger pull-right"  style="margin-right: 10px;">Delete</button>
                                        <ul class="nav nav-pills pull-right" style="margin-right: 10px; margin-bottom: 0px;">
                                            <li><a href="javascript:void(0);" onclick="$(this).parents('.editor').removeClass('active');">Cancel</a></li>
                                        </ul>
                                    </div>
                                    <div class="clearfix"></div>
                                </fieldset>
                            </form>
                            </div>
                        </div>
                    </li>


                    <!--<li class="header"><a href="#/data/{{$parent.MENU[$index].id}}" onclick="return false;">{{$index}}: {{menu.title}}</a></li>-->
                    <li data-ng-repeat="$admin in admins.data | filter:{parent_id:$parent.MENU[$index].id}">
                        <a data-ng-builder data-ng-click="$parent.addBreadcrumbItem($admin, ($parent.$index + 1) );" ng-class="{active: ($parent.SELECT_PARENT==admin.id)}">{{$admin.reference_data.code}} <span class="pull-right icon-chevron-right"></span></a>
                    </li>               



                </ul>
            </div>

我的问题是如何根本不呈现表单,而不是用 ng-show 或 ng-if 隐藏它

4

2 回答 2

2

ng-switch旨在做到这一点。它实际上根据条件将项目删除并插入到 DOM 中。

于 2013-08-01T12:01:00.270 回答
0

为此,我通常使用 angular-ui 中的 ui-if。

https://github.com/angular/angular.js/blob/master/src/ng/directive/ngIf.js

于 2013-08-01T12:01:58.977 回答