来自服务动态数据的 nsRouterLink Nativescript

冷安德鲁

我有来自服务的数组

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 导航中找不到任何指南,请指导。在 angular 2 web 中我可以处理它,但我不知道如何在 nativescript 中处理它。

谢谢你。

弗拉基米尔·阿米奥尔科夫(Vladimir Amiorkov)

简单地做这样的路线:

private items = new Array<Item>(
        { id: 1, name: "Batman", link: "/batmanscreen" },
        { id: 3, name: "doraemon", link: "/dorascreen" },

并像往常一样在 Angular 的 HTML 中进行绑定(使用 {N} + Angular 时没有 XML):

<Label [nsRouterLink]="item.link" text="go TO Screen" ></Label>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章