我想在angular 4应用程序中实现动态路由.我想要做的是将新的Route对象推送到Router config.代码看起来像
@
NgModule({
declarations: [
AppViewComponent
],
imports: [
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'appview', component: AppViewComponent }
{ path: '**', redirectTo: 'home' }
])
],
providers: []})
export class AppModuleShared {
constructor(router: Router, routerModule: RouterModule) {
console.log('Routes: ', JSON.stringify(router.config, undefined, 1));
router.config.push({ path: 'new/random/path', component: AppViewComponent });
router.config.forEach((x, i) => {
console.log(`${i}: ${JSON.stringify(x, undefined, 1)}`);
});
}}
Run Code Online (Sandbox Code Playgroud)
当应用程序启动时,我想将新的Route Object推送到配置并转到构造函数中的新路径.执行构造函数后,在控制台日志中我有这样的事情:
5: {
"path": "new/random/path"
}
Run Code Online (Sandbox Code Playgroud)
看起来新的Route …
我有一个问题,我试图解决约3天,我找不到任何有效的解决方案.问题是当我尝试连接localhost和端口62001时,我无法将我的nox播放器连接到adb.我所做的一切都是:
-nox_adb.exe
nox_adb.exe连接127.0.0.1:62001 - >无法连接到127.0.0.1:62001.
nox_adb.exe连接127.0.0.1:5037 - >连接到127.0.0.1:5037(但是当我尝试使用此deviceId运行反应本机项目时,它返回"没有连接Android设备")
-adb.exe(来自Android SDK)
adb.exe connect 127.0.0.1:62001 - >无法连接到127.0.0.1:62001.
adb.exe connect 127.0.0.1:5037 - >无法连接到127.0.0.1:5037.
我安装了整个android工作室(我认为)所需的库,谷歌USB驱动程序,sdk平台等.平台:Windows 7 x64 Nox:6.2.0.0
我读过了:
有人能告诉我我做错了什么吗?
先感谢您.