【发布时间】:2016-12-12 01:15:25
【问题描述】:
我想为 web 和 android 创建一个应用程序: https://github.com/NathanWalker/nativescript-ng2-magic。 我创建了 2 个组件 HomePageComponent 和 AddPageComponent 但这段代码似乎在我的 app.component.tns.html 中不起作用:
<page-router-outlet></page-router-outlet>
它应该显示我的 homepage.component.tns.html 中的内容:
<ActionBar title="Home Page"></ActionBar>
这是我的 app.routing.ts 中的代码
import {HomePageComponent} from "./components/homepage/homepage.component";
import {AddPageComponent} from "./components/addpage/addpage.component";
export const AppRoutes: any= [
{path:'', component: HomePageComponent},
{path:'addpage', component: AddPageComponent}
];
export const AppComponents: any = [
HomePageComponent,
AddPageComponent
];
以及 app.module.ts 的代码:
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/platform";
import {AppRoutes, AppComponents} from "./app.routing";
import {NativeScriptRouterModule} from "nativescript-angular/router";
import {NativeScriptFormsModule} from "nativescript-angular/forms"
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent, ...AppComponents],
imports: [
BrowserModule,
FormsModule,
HttpModule,
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(AppRoutes)
],
schemas: [NO_ERRORS_SCHEMA],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
【问题讨论】:
标签: android angular angular2-routing nativescript