删除在AngularJS中动态创建的部分视图

时间:2018-05-02 15:40:04

标签: angularjs angularjs-directive

我创建了一个重复的局部视图,现在我要删除动态创建的。

这是我的主视图my-custom-row-template是将重复注入的部分内容。

<section class="main_container">
    <div class="container">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <form ng-submit="addNew()">
                                <table class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th><input type="checkbox" ng-model="selectedAll" ng-click="checkAll()"/></th>
                                        <th scope="col">Setup Responses</th>
                                        <th>Add Condition</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="personalDetail in personalDetails">
                                        <td scope="col">
                                            <input type="checkbox" ng-model="personalDetail.selected"/>
                                        </td>
                                        <td scope="col" class="col-xs-10">

                                            <!--<div ng-repeat="condition_set in conditions" my-custom-row-template> </div>-->
                                            <div ng-repeat="condition_set in conditions track by $index"
                                                 my-custom-row-template></div>
                                            <!--<div my-custom-row-template></div>-->
                                        </td>
                                        </td>
                                        <td scope="col">

                                            <input type="button" value="Add Condition" ng-click="addCondition()"
                                                   class="btn btn-primary addnew"/>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                                <div class="form-group">
                                    <input ng-hide="!personalDetails.length" type="button"
                                           class="btn btn-danger pull-right"
                                           ng-click="remove()" value="Remove">
                                    <input type="submit" class="btn btn-primary addnew pull-right" value="Add New">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
</span>

这是我的部分观点

<div class="col-xs-8 pull-left">
    <div class="row form-group">
        <select style="color: black;">
            <option>Response Message</option>
            <option>IF</option>
            <option>Else</option>
        </select>
        <input type="text" class="form-control" ng-model="personalDetail.message"/>
        <select style="color: black;">
            <option>Step 2</option>
        </select>
        <select style="color: black;">
            <option>Add Step</option>
        </select>
        <input type="button" value="Remove Condition" ng-click="remove_condition(my-custom-row-template)"
               class="btn btn-danger"/>
    </div>

</div>

这就是我试图获取当前元素并将其删除的方式,但我得到的是0。如何删除当前单击的Partial?

$scope.remove_condition = function (element) {
                        console.log(element);
                    };

任何1可以告诉我如何删除当前的部分视图。

0 个答案:

没有答案