NativeScript Angular:如何重定向到子嵌套路由?

时间:2018-12-31 21:42:40

标签: nativescript angular2-nativescript nativescript-angular

我使用的是NativeScript Angular,无法弄清楚如何设置默认视图以使用children嵌套的路由路径。

传达我要完成的任务的最简单方法是在这里看着我的操场:https://play.nativescript.org/?template=play-ng&id=WvQnzu&v=581

打开app/home/home-routing.module.ts,在第9行上,您可以看到我正在尝试重新定向初始页面视图以将first子组件加载到{中定义的<router-outlet>中{1}}

我可以通过单击按钮或使用程序化的home.component.html(请参见<router-outlet>第47行)将嵌套的this.routerExtensions.navigate()中的子组件加载到

我在做什么错?为什么home.component.ts的初始加载没有在嵌套的HomeComponent中显示FirstComponent子级??

我只想使用 custom 标签导航,并在单击标签导航项时加载组件。

额外功劳:我看到<router-outlet>用在路线中,还有这个时髦的outlet名为出口符号。示例:[modal-navigation-ng] e2e应用1。此符号/机制是否记录在任何地方?我有点了解发生了什么,但似乎有些黑匣子/魔术。我只看e2e example app

就不能完全理解这个概念。

1 个答案:

答案 0 :(得分:1)

Angular不支持多层绝对重定向。

来源:https://github.com/angular/angular/issues/25254

一个简单的解决方法是使用相对重定向

应用路由

<taskdef name="aggregate" 
         classname="net.serenitybdd.ant.SerenityReportingTask" >
    <classpath>
        <pathelement location="${basedir}/lib/test/serenity-ant-task-1.5.8.jar"/>
        <pathelement location="${basedir}/lib/test/guice-4.1.0.jar"/>
        <pathelement location="${basedir}/lib/test/guava-22.0.jar"/>
        <pathelement location="${basedir}/lib/test/serenity-core-1.5.8.jar"/>
        <pathelement location="${basedir}/lib/test/serenity-junit-1.5.8.jar"/>
        <pathelement location="${basedir}/lib/test/slf4j-api-1.7.21.jar"/>
        <pathelement location="${basedir}/lib/test/javax.inject-1.jar"/>
        <pathelement location="${basedir}/lib/test/aopalliance-1.0.jar"/>
        <pathelement location="${basedir}/lib/test/freemarker-2.3.23.jar"/>
        <pathelement location="${basedir}/lib/test/gson-2.8.0.jar"/>
        <pathelement location="${basedir}/lib/test/java-client-5.0.0-BETA9.jar"/>
        <pathelement location="${basedir}/lib/test/selenium-support-3.5.2.jar"/>
        <pathelement location="${basedir}/lib/test/selenium-api-3.5.2.jar"/>
        <pathelement location="${basedir}/lib/test/asciidoctor-java-integration-0.1.4.jar"/>
        <pathelement location="${basedir}/lib/test/commons-lang3-3.4.jar"/>
        <pathelement location="${basedir}/lib/test/config-1.3.1.jar"/>
        <pathelement location="${basedir}/lib/test/*"/>
    </classpath>
</taskdef>

<target name="junit" depends="compile, manifest.jar">

    <junit printsummary="yes" haltonfailure="no" fork="yes" showoutput="yes">

        <!-- Serenity system properties. -->
        <sysproperty key="included.packages" value="edu.umd.cs.findbugs" />
        <sysproperty key="included.adapters" value="coverage,complexity,dependency" />

        <!-- Project classpath, must include junit.jar -->
        <classpath refid="manifest.classpath" />

        <!-- test class -->
        <classpath location="${build.compile.dir}" />

        <formatter type="plain" />

        <batchtest fork="yes" todir="${basedir}">
            <fileset dir="${src.dir}">
                <include name="**/*Test*.java" />
            </fileset>
        </batchtest>

    </junit>
    <!-- Build the aggregate Serenity Report -->
    <aggregate  sourceDirectory="${basedir}/target/site/serenity" 
            outputDirectory="${basedir}/target/site/serenity" />
</target>
enter code here

家庭路由

map
相关问题