我有来自服务的数组
private items = new Array<Item>(
{ id: 1, name: "Batman", link: "batmanscreen" },
{ id: 3, name: "doraemon", link: "dorascreen" },
...........
,
XML组件如:
<ActionBar title="Details" class="action-bar"></ActionBar>
<FlexboxLayout flexDirection="column" class="page">
<FlexboxLayout class="m-15">
<Label class="h2" [text]="item.id + '. '"></Label>
<Label class="h2" [text]="item.name"></Label>
</FlexboxLayout>
<Label class="h4" [text]="item.link"></Label>
<Label [nsRouterLink]="['/item.link']" text="go TO Screen" ></Label>
</FlexboxLayout>
和单击链接时Android模拟器上的结果:
EXCEPTION: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'item.link'
我期待成为 nsRouterLink = "['/batmanscreen']"
,但在nativescript导航中找不到任何指南,请指导 . 在角度2网络我可以处理它,但我不知道如何在nativescript中做到这一点..
谢谢 .
2 回答
简单地做这样的路线:
并且通常在Angular的HTML中进行绑定(当使用 Angular时,没有XML):
所以你期待
['/item.link']
评估为['/batmanscreen']
?那个'/item.link'
只是一个字符串文字,所以它希望能够实现这个目标's not replaced by ' batmanscreen ' as you' .请尝试这样:
['/' + item.link]
.