2017-12-31 46 views
0

Ich habe ein Array mit Artikeln gefüllt, zeigt ein Element:Ändern Staaten mit AngularJS aus einem Array mit Element

$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); 

Ich möchte meinen Zustand der Evolution-Debatte Zustand ändern:

.state("evolution-debate", { 
     url: "/evolution-debate", 
     templateUrl: "templates/articles/evolution-debate.html", 
     controller: 'articles' 
    }) 

Da ich jedoch meine Artikel aus dem Array lade, muss ich den Status ändern, indem ich die artikel.link -Eigenschaft von meinem Array-Objekt verwende.

Ich bin derzeit mit diesem Code, aber es wird den Zustand nicht ändern:

<ul class="actions"> 
    <li><a ng-click="go('{{article.link}}')" class="button big">READ NOW</a></li> 
</ul> 

Jede mögliche Hilfe würde geschätzt.

+1

Sie READ NOW verwenden können, um navigieren zu Ihrem Artikel – NTP

+0

Ich bin froh, dass ich helfen konnte zu navigieren. Wenn jemand ein ähnliches Problem hat, ist es leichter, Antworten zu folgen als Kommentare. – NTP

Antwort

2

können Sie ui-sref verwenden, um Ihre Artikel

<a ui-sref="{{article.link}}">READ NOW</a> 
Verwandte Themen