AngularJs - 提交按钮多次重复

时间:2016-01-08 12:10:40

标签: javascript angularjs forms button submit

我正在AngularJS的ACTIVI工作。

我需要提交表单,所以我用提交按钮创建了表单。问题是每个提交按钮有点不同(一个用于文本类型表单,另一个用于枚举类型表单),而对于新表单,先前的按钮重复两次。 你可以看到这个没问题:

enter image description here

但是下一个表单会重复之前的提交按钮:

enter image description here

这是html中的代码

<div ng-controller="githubController3">
                <div ng-controller="githubControllerForm1">
                    <div ng-controller="completeTaskAction">
                        <form ng-submit="submitForm()">
                            <div ng-repeat="x in names">
                                {{ x.name }}*


                                <div ng-if="x.id=='name'">
                                    <input type="text" name="nome" ng-model="formData.properties[0].value" placeholder="{{x.name}}"> {{ value }} </input>
                                </div>

                                <div ng-if="x.id=='email'">
                                    <input type="email" name="email" ng-model="formData.properties[1].value" placeholder="{{x.name}}"> {{ email }} </input>
                                </div>

                                <div ng-if="x.id=='income'">
                                    <input type="number" name="numero" ng-model="formData.properties[2].value" placeholder="{{x.name}}"> {{ income }} </input>
                                </div>
                            </div>
                    </div>
                    </form>
                    <div ng-controller="completeTaskAction">
                        <form ng-submit="submitForm()">
                            <br>
                            <button ng-show="x.type==enum" type="submit" class="btn btn-success btn-lg btn-block">
                                <span class="glyphicon glyphicon-flash"></span>Submit!
                            </button>
                    </div>
                    </form>
                </div>
            </div>

            <div ng-controller="githubControllerForm1">
                <div ng-controller="completeTaskAction2">
                    <div ng-repeat="x in names">

                        <div ng-if="x.type=='enum'">
                            <!--/////////////////////////////////-->


                            <form ng-submit="submitForm2()">

                                <select ng-model="formData2.properties[0].value" ng-options="y.id as y.name for y in x.enumValues "></select>




                                <br>

                                <button ng-hide="x.type==enum" type="submit" class="btn btn-success btn-lg btn-block">
                                    <span class="glyphicon glyphicon-flash"></span> Submit!
                                </button>
                        </div>

                    </div>
                    </form>
                </div>

            </div>

我试过(如你所见)使用ng-show / hide / ng-if但是没有用...

1 个答案:

答案 0 :(得分:0)

第一种形式工作正常,因为按钮在ng-repeat之外。在第二种情况下,提交按钮在ng-repeat内。