angular - 在 Ionic 2 应用程序中使用 Angular 2 路由器是否有意义?

标签 angular typescript ionic2 angular2-routing ng-modules

我们已经尝试将我们的 Angular 2 应用程序(由我们的一个 friend 编写,因此我们可能不知道所有细节)迁移到 Ionic 2。但是,我们还没有设法让它工作,因此问题下面。

  1. Angular 2 路由器可以在 Ionic 2 中工作吗?
  2. 在 Ionic 2 应用程序中使用 Angular 2 路由器是否有意义,或者我们应该直接使用替代方案,例如 DeepLinker

编辑:我不确定当前状态是什么,但我读到了 here那:

«The Angular router is currently under heavy development and refactoring. As a result of this, Angular’s router is currently disabled within Ionic.»

  1. 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 是一场噩梦。不过这很好,直到……

我们使用 Ionic 的原因是一次开发,多次部署。网络、手机/平板电脑和可能的 Windows(Linux?)...

但仅仅想到,我们正在构建的应用程序在网络上看起来很糟糕,就像一个放大的移动应用程序。我试了一下,想我会稍微调整一下。但是,我会放弃整个最初的想法,不得不维护多个代码库。

这个,在用户界面部分。但后来我发现随着 Ng2 的到来和发展,Ionic 也选择引入 NavController,而不是等待(响应式(Reactive))Router ......这就是事情变得困惑的地方......所以,除了不得不担心两个UI 的代码库,我还必须为 Router/NavController 冲突重写它。

与此同时,我的目光落在了 Minks Gechev's Angular Seed 上并成功地将 Ionic 碱与它混合。

在对 Ionic Github Issue 进行了沉默的讨论之后,超过 15 个人分享了我对 NavController 问题的担忧。其中一位 Ionic 核心开发人员试图让我们闭嘴,告诉我们“它很快就会解决”,对此我要求“尽快定义”。他差点把我踢出去。

与此同时,我只是对 Nathan's Angular Advanced Seed 感到兴奋. Nathan 为 Telerik 工作,Telerik 是开源 Nativescript 背后的驱动程序(现在它本身是一个独立的基金会)

起初,我持怀疑态度,因为 Telerik 倾向于过度 promise 。我试过尝试它,但它确实更快,而且它不是混合的,它是原生的。

我自己确实喜欢 flexbox。所以,我会使用它搜索一个(网络/Windows)用户界面。为什么不泡温泉?

所以,去 Nathan 的种子,把温泉放进去。这是前端。后端 - Keycloak 和 vert.x

关于angular - 在 Ionic 2 应用程序中使用 Angular 2 路由器是否有意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42168775/

相关文章:

javascript - Angular FormGroup.value 将值放入数组中

angular - 从不同的仓库导入组件

Angular 2 native 桌面应用程序(没有 Electron)示例

javascript - 如何将base64转换为普通图片URL?

Typescript:空检查在 array.map 函数内不起作用

node.js - Ionic 2 找不到模块 'dgram'

jquery - 使用高亮filterData在全局变量上不显示过滤器数据意味着不在Typescript中的功能

typescript - 错误 : Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning

angular - 如何计算 ionic 选择Childs( ionic 选项)?

css - 缩小 Ionic >=2 警报的媒体查询在 IOS 上不起作用