Angular 角度布线与离子布线
我是新来的ionic2。与纯角度布线相比,它的布线有些奇怪。在角度上:Angular 角度布线与离子布线,angular,ionic2,angular2-routing,Angular,Ionic2,Angular2 Routing,我是新来的ionic2。与纯角度布线相比,它的布线有些奇怪。在角度上: const appRoutes: Routes = [ { path: 'crisis-center', component: CrisisListComponent }, { path: 'hero/:id', component: HeroDetailComponent }, { path: 'heroes', component: HeroListComponent, da
const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent },
{ path: 'hero/:id', component: HeroDetailComponent },
{
path: 'heroes',
component: HeroListComponent,
data: { title: 'Heroes List' }
},
{ path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
// other imports here
],
我们传递一个带有路由类型的常量
在Ionic(启动器)中,它们将一个组件传递给forRoot
函数
import { MyApp } from './app.component';
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
],
有什么想法吗?编辑:
爱奥尼亚4也在后台使用标准的角度路由。推和弹出不再是爱奥尼亚的方式,它是使用爱奥尼亚角度路由的好读物
原始答案:
Ionic不支持URL路由,而是实现了一个自定义导航解决方案(由suraj链接)。NavController维护页面堆栈-向前移动时,将页面推送到堆栈this.nav.push(Page1)代码>并向后移动,弹出它this.navCtrl.pop()代码>。
这样,浏览器中的url总是相同的,应用程序总是在主页上打开,这类似于移动应用程序的行为。为了能够直接访问您必须使用的特定资源(正如您打开url myapp/items/1一样)。在爱奥尼亚,我们从另一个视图推送视图屏幕
但在angular中,是预定义的路由映射,如果您转到此路由,即应用程序/登录,您将被重定向到与loginComponent绑定的登录路由?它在新的离子(4+)中非常好。