角js渲染如果

时间:2013-08-01 11:53:22

标签: javascript angularjs

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

这是我的代码:

<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

隐藏它

2 个答案:

答案 0 :(得分:2)

ng-switch旨在做到这一点。它实际上会根据条件删除和插入DOM。

答案 1 :(得分:0)