Angularjs 发布ng模型和ng重复、重复表格

Angularjs 发布ng模型和ng重复、重复表格,angularjs,angularjs-directive,angularjs-ng-repeat,angular-ngmodel,Angularjs,Angularjs Directive,Angularjs Ng Repeat,Angular Ngmodel,我有一个页面,其中基于ng repeat创建了多个表单。一切都正常工作,直到将某些内容写入输入,并且所有其他重复表单输入元素上的内容都被复制。我使用了ng model=“Notify.message”,它只不过是一个对象,从输入中获取值,并在按钮提交时发送给控件,从而发送其余逻辑 我在寻找,如果一个表格已经填写,其他表格应该保持安静,不应该重复在表格1的输入文本中写的值 代码如下: <div data-ng-show="alluserposts.length > 0">

我有一个页面,其中基于
ng repeat
创建了多个表单。一切都正常工作,直到将某些内容写入输入,并且所有其他重复表单输入元素上的内容都被复制。我使用了
ng model=“Notify.message”
,它只不过是一个对象,从输入中获取值,并在按钮提交时发送给控件,从而发送其余逻辑

我在寻找,如果一个表格已经填写,其他表格应该保持安静,不应该重复在表格1的输入文本中写的值

代码如下:

<div data-ng-show="alluserposts.length > 0">
    <div id="b{{userpost.id}}" data-ng-repeat="userpost in alluserposts" >
            <div class="row" style="margin-left: -5px">
                <form class="text-center" role="form" id=f1{{userpost.id}} name="userForm"
                      ng-submit="notify(userForm.$valid, userpost, apiMe)" novalidate>
                    <div class="row">
                        <div class="col-xs-8 col-md-4">
                            <div class="form-group">
                                <input data-container="body" data-toggle="popover" data-placement="top"
                                       data-content="Any message which you would like to convey to post owner"
                                       type="text" ng-model="Notify.message" data-ng-init="Notify.message=''"
                                       id="u{{userpost.id}}"
                                       placeholder="Enter a Message or Phone number" class="form-control"
                                       required>

                                <p ng-show="userForm.name.$invalid && !userForm.name.$pristine" class="help-block">It is
                                    required.</p>
                                <script>$(function () {
                                    $("[data-toggle='popover']").popover();
                                });
                                </script>

                                <input type="hidden" ng-model="Notify.loggedInEmail"
                                       ng-init="Notify.loggedInEmail = result.email"/>
                                <input type="hidden" ng-model="Notify.postId" ng-init="Notify.postId = userpost.id"/>
                                <input type="hidden" ng-model="Notify.destEmail"
                                       ng-init="Notify.destEmail = userpost.userEmail"/>
                            </div>
                        </div>

                        <div ng-show="loginStatus.status == 'connected'" class="col-xs-4 col-md-2">
                            <button class="btn btn-primary" ng-disabled="userForm.$invalid || !userForm.$dirty"
                                    type="submit">
                                Notify Post Owner
                            </button>
                        </div>
                    </div>
                </form>
                </p>
            </div>
        </div>
    </div>
</div>

它是 必需的

$(函数(){ $(“[data toggle='popover']”).popover(); }); 通知邮件所有者

发行小提琴-


在这里,您可以在一个输入中写入某些内容时,另一个也会被填充:(.Notify是一个Java映射对象,message是其中的一个变量。请告诉我如何对其进行分段!

您将所有输入绑定到
$scope
上的同一个变量。 必须将每个文本框绑定到
$scope
上的不同变量:

视图:


我还处于
angularjs
的开始阶段

我几天前也遇到过同样的问题,并通过在
ng model
like中提供动态模型名称来解决它

<input type="text" ng-model="Notify[post.userEmail]" ng-init="Notify[post.userEmail] = post.userEmail" />

工作小提琴:

$scope.emails = [];
<input type="text" ng-model="Notify[post.userEmail]" ng-init="Notify[post.userEmail] = post.userEmail" />