简体   繁体   English

ng-repeat在模式中不起作用

[英]ng-repeat won't work in modal

So I'm trying to get a modal to ng-repeat an array of objects and it won't show up at all. 因此,我尝试获取一种模式以ng-repeat对象的阵列,并且它根本不会显示。 I'm not quite sure what I'm doing wrong but hoping for help as to getting the ng-repeat to work! 我不太确定自己在做什么错,但希望就ng-repeat的工作寻求帮助!

    <div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
        <h4>Transfer Funds</h4>
    </div>
    <br />
    <div class="modal-body">
        <div class="row">
            <div class="col-md-12">
                <table class="table">
                    <thead>
                        <tr>
                            <th class="text-center">
                                eGift Cards
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="trans in gctrans.Items | filter: cardSearch">
                            <td class="text-center">
                                <strong>{{getCustomerName(trans)}}</strong>
                                <strong>{{getCustomerCardNumber(trans)}}</strong>
                                <small>{{getCustomerPhone(trans) | tel}}<br /></small>
                                <small> {{getCustomerEmail(trans)}}<br /></small>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<br />
<div class="modal-footer">
    <button class="btn btn-primary" ng-click="confirmTransfer(trans)">Next</button>
</div>
</div>

the two most likely things that would be causing this are model not existing in scope and filter causing unexpected behavior. 导致此问题的两个最可能的原因是范围内不存在模型,并且过滤器导致意外行为。 The first to try would be seeing if the gctrans.Items is available in the scope of the modal. 首先尝试的是查看gctrans.Items在模态范围内是否可用。 Try adding {{gctrans}} in the modal and see if any data is there, like: 尝试在模式中添加{{gctrans}} ,看看是否有任何数据,例如:

<div class="col-md-12">
   raw data: {{gctrans}}
   <table class="table">

second, if there is data try removing the filter: 第二,如果有数据,请尝试删除过滤器:

<tr ng-repeat="trans in gctrans.Items">

and one more thing to try, if the data is good and the filter is not unexpectedly removing items, you might not be selecting anything inside of the repeat. 再尝试一件事,如果数据良好,并且过滤器未意外删除项目,则可能未在重复项中选择任何内容。 Try just outputting the item 尝试仅输出项目

<tr ng-repeat="trans in gctrans.Items">
  <td class="text-center">
    <strong>{{trans}}</strong>
  </td>
</tr>

thanks so much for the input. 非常感谢您的投入。 I figured out what I had done wrong in the controller (hadn't declared gctrans in the modal function). 我发现我在控制器中做错了什么(在模态函数中未声明gctrans)。 Make sure all your stuff is declared in functions as well if you're using modals and ng-repeat! 如果您使用模态和ng-repeat,请确保在函数中也声明了所有东西!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM