How to use same path in loadChildren for Nativescript and Angular?

╄→гoц情女王★ 提交于 2019-12-11 07:53:29

问题


I have a project using Angular and Nativescript, and we'd like to use the same routes.

Here's how my routes look like:

    {
        path: '',
        component: BaseComponent
    },
    {
        path: 'details',
        //loadChildren: '~/app/Routes/base/details/details.module#DetailsModule',
        loadChildren: './details/details.module#DetailsModule',
    }

The commented one works on Nativescript, but not on Angular. The other one works on Angular but not on Nativescript.

How can I use the same path to lazy load my module in Nativescript AND Angular, without having 2 files?

Thanks in advance! Have a great day :)


回答1:


In case someone's having this problem, you can do this:

{
    path: '',
    component: BaseComponent
},
{
    path: 'details',
    loadChildren: () => DetailsModule,
}

The import is a relative path and work wit both of the platform



来源:https://stackoverflow.com/questions/54361588/how-to-use-same-path-in-loadchildren-for-nativescript-and-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!