如何将ng-model值传递给打开HTML叠加层的锚标记?

时间:2014-03-18 13:16:58

标签: html5 angularjs angularjs-scope angularjs-ng-repeat angular-ui

我有一个场景,我使用AngularJS在HTML页面上显示很多帖子,每个帖子在点击时都会在叠加层中显示相关数据。数据使用ng-repeat标记显示在主页上,当点击任何一个项目时,将打开同一页面中定义的HTML叠加层。

问题:

每个项目只显示第一个结果,即每当我点击任何具有不同ID的帖子时,它都会打开,只显示第一个ID。那是不对的。例如,如果我的结果是:

  1. 温莎酒店,
  2. Chancery
  3. le Merridian。
  4. 每当打开叠加层时,它总会显示所有人的温莎。

    以下是代码。请建议。::

    <div ng-repeat="post in allposts" style="background-color: #f8efc0" class="col-xs-10 col-md-11">
        <div>
            <a href="http://www.jquery2dotnet.com/2013/10/google-style-login-page-desing-usign.html">{{ post.postText}}</a>
            <div class="mic-info">
                By: <a href="#">{{ post.userEmail}}</a> on 2 March 2014
            </div>
        </div>
        <div class="action">
            <a href="#" class="btn btn-default btn-primary btn-xs">Your post is really helpful
                                                        <span class="glyphicon glyphicon-thumbs-up"></span></a>
            <a href="#" class="btn btn-default btn-warning btn-xs active">would suggest, be
                                                        specific in your requirement <span
                                                            class="glyphicon glyphicon-thumbs-down"></span></a>
            <!-- <button type="button" class="btn btn-danger btn-xs" title="Delete">
                                                         <span class="glyphicon glyphicon-trash"></span>
                                                     </button>-->
        </div>
        <a href="#"
            data-toggle="modal"
            data-target="#t_and_c_m">Comments of the post!</a>
        <div class="modal fade" id="t_and_c_m" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title" id="myModalLabel">Terms & Conditions</h4>
                    </div>
                    <div class="modal-body">
                        <div id="disqus_thread"></div>
                        <script type="text/javascript">
                            /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    
                            var disqus_shortname = 'pingled'; // required: replace example with your forum shortname
    
                            var disqus_identifier = 'postid';
    
                            alert(disqus_identifier);
    
                            var disqus_url = '';
    
                            /* * * DON'T EDIT BELOW THIS LINE * * */
                            (function () {
                                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                                dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
                            })();
    
                            disqus_shortname = 'pingled'; // required: replace example with your forum shortname
    
                            disqus_identifier = undefined;
    
                            disqus_url = undefined;
    
                        </script>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
    

1 个答案:

答案 0 :(得分:0)

您可以尝试将数据传递到bootstrap 3模式,如下所示:Passing data to a bootstrap modal,作为数据ID参数:data-toggle =“modal”data-id =“{{post.id}}”...