Angularjs 使用ng-repeat打开模型

Angularjs 使用ng-repeat打开模型,angularjs,Angularjs,我的问题是,每次我点击任何项目弹出窗口时,都会打开第一个项目数据,而不是点击的项目数据。 请查找代码以供参考: <div class="quote-inner-section"> <div class="col-xs-6 col-md-6 quote-wrapper" ng-repeat="appreciate in customerQuotes | filter:search"> <div

我的问题是,每次我点击任何项目弹出窗口时,都会打开第一个项目数据,而不是点击的项目数据。 请查找代码以供参考:

<div class="quote-inner-section">
                <div class="col-xs-6 col-md-6  quote-wrapper" ng-repeat="appreciate in customerQuotes | filter:search">
                    <div class="quote-wrapper-inner thumbnail" data-toggle="modal" data-target="#myModal" ng-click="modal.selected = clientquote"> 
                        <div class="appreciator-snap">
                            <figure class="appreciator1">
                                <img src="modules/main/img/icon_user.png" class="img-responsive img-circle" width="35">
                            </figure>
                            <div class="pointer"></div>
                            <figure class="appreciator2">
                                <img src="modules/main/img/icon_user.png" class="img-responsive img-circle" width="45">
                            </figure>
                        </div>
                        <div class="tile-content">
                            <div class="keymetric-based">
                                <div class="appreciation-box">
                                    <span class="quote-name" ng-model="writer" ng-bind="appreciate.by"></span>
                                    <span class="arrow-right">&#9658;</span>
                                    <span class="quote-name"  ng-bind="appreciate.to"></span>
                                    <span class="badge quote-date"> 5 days ago</span>
                                </div>
                                <div class="quote-details">
                                    <blockquote class="truncate">
                                      <p>{{appreciate.description}}</p>
                                        <span class = "dotThree">....Read more</span>
                                    </blockquote>
                                </div>
                            </div>                  
                        </div>
                    </div>
                    <div class="modal fade col-md-6 col-sm-6" id="myModal" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                          </div>
                          <div class="modal-body" >                            
                            <p>Written by <span   ng-model="writer">{{appreciate.by}}</span></p>
                            <p>To <span  >{{appreciate.to}}</span></p>
                            <p>Description:  <span  >{{appreciate.description}}</span>  </p>
                            <p>Date : <span> {{date | date:'yyyy-MM-dd'}}</span></p>
                          </div>
                          <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                          </div>
                        </div>
                       </div>
                    </div> 
            </div>
            <div class="clearfix"> </div>            
               <nav style="padding-left:15px;">
                  <ul class="pagination">
                    <li>
                      <a href="#" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                      </a>
                    </li>
                    <li class="active"><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <li><a href="#">4</a></li>
                    <li><a href="#">5</a></li>
                    <li>
                      <a href="#" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                      </a>
                    </li>
                  </ul>
                </nav>
            </div>

►
5天前
{{欣赏.描述}

阅读更多 &时代; 作者{{感激.by}

感谢

Description:{{permission.Description}}

日期:{Date}日期:'yyyy-MM-dd'}

接近

这是我在模式窗口中打开项目的方式

    $scope.viewItem = function (item) {
    var modalInstance = $modal.open({
        templateUrl: 'viewItem.html',
        controller: 'viewItemInstanceCtrl',
        size: 'lg',
        resolve: {
            item: function() {
                return item;
            }
        }
    });
    modalInstance.result.then(function (editable) {

    }, function () {
        $log.info('Modal dismissed at: ' + new Date());
    });
};
然后在我的html中,当我调用函数时,我传递该项

ng-click='viewItem(itemObject)'

我是否正确理解了问题?

这是我在模式窗口中打开项目的方式

    $scope.viewItem = function (item) {
    var modalInstance = $modal.open({
        templateUrl: 'viewItem.html',
        controller: 'viewItemInstanceCtrl',
        size: 'lg',
        resolve: {
            item: function() {
                return item;
            }
        }
    });
    modalInstance.result.then(function (editable) {

    }, function () {
        $log.info('Modal dismissed at: ' + new Date());
    });
};
然后在我的html中,当我调用函数时,我传递该项

ng-click='viewItem(itemObject)'

我是否正确理解了这个问题?

通过添加{{$index}修复了这个问题

更新我的HTML如下:

待命:数据目标=“#myModal{{{$index}”


在model:id=“myModal{{$index}}”

中添加了{{$index}修复了这个问题

更新我的HTML如下:

待命:数据目标=“#myModal{{{$index}”


关于model:id=“myModal{{{$index}}”

好的……谢谢,但我想用currect结构制作弹出模式。除了循环问题外,一切都很好,当我点击ng Repeat的任何元素时,只有第一个项目出现。是的,编辑完成后我看到了(以前没有看到代码),我现在正在查看它,将查看是否可以帮助确定…谢谢,但我想用currect结构制作弹出模式。除了循环问题外,我一切正常,当我单击ng repeatyeah的任何元素时,只有第一项出现。我在编辑完成后看到(以前没有看到代码)我现在正在查看它,将查看我是否可以帮助“clientquote”是“赞赏”的属性吗?ng click=“modal.selected=clientquote”不是“赞赏”的属性。我试着把它取下来,没有区别。所以完全删除了它,因为如果我猜它应该是ng click=“modal.selected=precure”(与当前的precure in循环一样),我将它更新为ng click=“modal.selected=precure”,但它仍然不工作。我想可能是因为modal div在ng repeat循环中是“clientquote”的一个属性“precure”?ng click=“modal.selected=clientquote”不是赞赏的属性。我尝试删除它,但没有区别。因此完全删除了它Yok,因为如果我认为它应该是ng click=“modal.selected=赞赏”(与当前的赞赏循环一样),我将其更新为ng click=“modal.selected=赞赏”“但是它仍然不起作用,我想可能是因为modal div在ng repeat循环中