我有一个充满文章的数组,显示一个元素:
$scope.articles = [];
//New article
var article = {};
article.heading = "A DISCUSSION WITH ATHEISTS ON EVOLUTION";
article.date = "December 24, 2017";
article.description = "The point of my discussion was to attempt to convince a relatively large group of atheists in r/DebateAnAtheist that the theory of evolution which they hold on to so dearly is in fact a random process. It is generally maintained that evolution is not random due to natural selection. This idea, however, is fundamentally flawed.";
article.link = "evolution-debate";
article.img = "templates/articles/evolution-debate/darwin.jpg";
//Add to array
$scope.articles.push(article);
我想将我的状态更改为进化辩论状态:
.state("evolution-debate", {
url: "/evolution-debate",
templateUrl: "templates/articles/evolution-debate.html",
controller: 'articles'
})
但是由于我从数组加载文章,因此我需要使用数组对象中的article.link 属性更改状态。
我当前正在使用此代码,但它不会改变状态:
<ul class="actions">
<li><a ng-click="go('{{article.link}}')" class="button big">READ NOW</a></li>
</ul>
如有任何帮助,我们将不胜感激。
最佳答案
您可以使用 ui-sref 导航到您的文章
<a ui-sref="{{article.link}}">READ NOW</a>
关于javascript - 使用数组中的元素通过 AngularJS 更改状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48041640/