我有納克重複顯示的對象的數組:角:使對象數組的索引從NG-重複訪問對象數據
<div class = "row" ng-repeat="article in academicArticles">
<div class = "col-md-9 academicArticle" ng-click = "index = $index">
<a ui-sref ="article">
<h2> {{article.title}} </h2>
<p> {{academicArticles.indexOf(article)}} </p>
<img src = "{{article.img}}" class = "img-responsive">
</a>
</div>
</div>
我想顯示在另一狀態下的選擇的「物品」。現在,我有:
<div class ="container">
<div class = "jumbotron">
<img src = "../../../photos/danielpark.jpg">
<h1>{{academicArticles[index].title}}</h1>
<p> Written By: {{academicArticles[index].author}} </p>
</div>
</div>
沒有錯誤,但{{academicArticles[index].author}}
和{{academicArticles[index].title}
是空白。我如何在另一個狀態訪問所選文章的數據?
最簡單的方法是使用url參數傳遞url中的文章ID,並在其他狀態下使用該ID獲取該文章。對於鏈接將像'ui-sref =「article({id:article.id})」' – charlietfl