【发布时间】:2017-06-29 08:32:40
【问题描述】:
我们已经尝试将我们的 Angular 2 应用程序(由我们的朋友编写,因此我们可能不知道所有细节)迁移到 Ionic 2 中。但是,我们还没有设法使其工作,因此提出疑问下面。
- Angular 2 路由器可以在 Ionic 2 中工作吗?
- 在 Ionic 2 应用程序中使用 Angular 2 路由器是否有意义,或者我们应该直接使用替代方案,例如 DeepLinker?
编辑:我不确定当前状态是什么,但我读到 here 说:
«Angular 路由器目前正在进行大量开发和重构。因此,Angular 的路由器目前在 Ionic 中被禁用。»
-
在code/metadata/build-script/
package.json中哪里是激活路由器的入口点?我们在 NgModule 中有路由,但是当我们访问应用程序的主 URL 或子 URL 时,它似乎没有启动:@NgModule({ declarations: [ AppComponent, TestComponent, AgendasListComponent, TasksListComponent, SnackBarComponent, ConfirmationDialog, AgendaComponent, LoginComponent ], entryComponents: [ ConfirmationDialog ], imports: [ BrowserModule, HttpModule, MaterialModule.forRoot(), AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig), RouterModule.forRoot([ { path: '', redirectTo: 'agendas', pathMatch: 'full', canActivate:[ RouterGuardService ] }, { path: 'agendas', component: AgendasListComponent, canActivate:[ RouterGuardService ] } ...
【问题讨论】:
-
Ionic 在 Angular 2 上运行,因此代码库将是兼容的。如果您对 ionic 有特定问题,请发布一个可运行的代码示例来演示该问题
-
谢谢@codeninja。我知道它应该可以工作,但我对 here 所说的关于在 Ionic 中禁用角度路由器表示怀疑:
The Angular router is currently under heavy development and refactoring. As a result of this, Angular’s router is currently disabled within Ionic.不确定是否仍然如此。 -
也不确定,但是查看他们有关导航的文档,您似乎可以像在 ios 中一样通过将视图推送到导航堆栈来进行导航。如果这不适合您可以选择不使用 ionic 而只使用cordova 或类似的
-
为什么不使用 ionic 2 的内置导航?
-
嗯,我想你会花更多的时间让它工作,而不是仅仅使用已经内置的导航系统,它非常完整且易于使用
标签: angular typescript ionic2 angular2-routing ng-modules