在页面中路由未发生。我已经使用了HTML和配置代码。routerLink未在角度2中工作
<nav aria-label="Page navigation">
<ul class="pagination pagination-plain">
<li>
<a href="review/words" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li [routerLinkActive]="['active']">
<a [routerLink]="review/words">1</a>
</li>
<li [routerLinkActive]="['active']">
<a [routerLink]="review/phrase">2</a>
</li>
<li>
<a href="javascript:void(0)" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
路由配置代码
const appRoutes: Routes = [
{
path: '',
component: IndexComponent,
},
{
path: 'index',
component: IndexComponent,
},
{
path: 'review/words',
component: WordsComponent,
},
{
path: 'review/phrase',
component: SentenceComponent,
}
];
我收到的时候我在分页链接点击“1”或“2”下面的错误。
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'review/phrase/NaN' Error: Cannot match any routes. URL Segment: 'review/phrase/NaN' at ApplyRedirects.noMatchError (router.es5.js:1404) [angular] at CatchSubscriber.selector (router.es5.js:1379) [angular] at CatchSubscriber.error (catch.js:104) [angular] at MapSubscriber.Subscriber._error (Subscriber.js:128) [angular] at MapSubscriber.Subscriber.error (Subscriber.js:102) [angular] at MapSubscriber.Subscriber._error (Subscriber.js:128) [angular] at MapSubscriber.Subscriber.error (Subscriber.js:102) [angular] at MapSubscriber.Subscriber._error (Subscriber.js:128) [angular] at MapSubscriber.Subscriber.error (Subscriber.js:102) [angular]
@Partha Ghiya:谢谢你的回答。它路由到URL。但是,除非我刷新它,否则页面不会被加载。你能帮忙吗? –
@GreenComputers导致你没有router-outlet。 添加此结果在您的HTML。 ' router-outlet>' –
@Partha Ghiya:已添加。但同样的问题。请帮忙。 –