数据在模态中无法正确显示

时间:2017-03-24 06:27:27

标签: angularjs twitter-bootstrap

我在两行中得到两个值,例如假设我的{{x.room_type}}在第一行显示A,在第二行显示B. href切换一个模式,当我点击时显示有关A的其他数据单击B行时有关B的行和其他数据。

<div class="row" ng-repeat="x in roomdata.data">

    <div class="well well-sm" >{{x.room_type}}<a href="#" data-toggle="modal" data-target="#room_detail" class="pull-right">Room Details</a>
    </div>
    <h5 class="pull-right">{{x.rack_price}}<br>Per room per night</h5>
    <img ng-src="{{room_image}}">

</div>

但是当我点击两行上的链接时,模态仅显示A的详细信息。

这是模态

<div class="modal" id="room_detail" ng-repeat="x in roomdata.data">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type = "button" class="btn btn-danger pull-right" data-dismiss="modal">&times;</button>
                <h3>{{x.room_type}} - {{current_Hotel.hotel_name}}</h3>
                <a href="" ng-click="show = 'desc'">Descriptions</a>
                <a href="" ng-click="show = 'pictures'">Room Pictures</a>
                <a href="" ng-click="show = 'amenities'">Amenities</a>
                <a href="" ng-click="show = 'others'">Others</a>
            </div>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:1)

您可以将$read$附加到您的ID,并为了使其有效,也可以在{{$index}}中添加。像这样:

data-toggle

而且,模态开启者就像,

<div class="modal" id="room_detail{{$index}}" ng-repeat="x in roomdata.data">

所以,现在所有的模态都有唯一的ID,这将有助于我们区分它们。

这是working example

相关问题