2016-07-03 12 views
0

nativescriptのクイック・スタート・デモをangular2で実行しようとしています。私がルータに来ると、それは失敗するようになりました。エラーメッセージ:RouterOutletMapのプロバイダがありません!Nativescript Angular2 Route Provider

import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router-deprecated/ns-router-deprecated";:ここhereは、あなたがこのよう"nativescript-angular/router-deprecated/ns-router-deprecated"

からNS_ROUTER_DIRECTIVESNS_ROUTER_PROVIDERSをインポートする必要があり nativescript githubの問題に解決策として

main.ts 
############# 
    import {nativeScriptBootstrap} from "nativescript-angular/application"; 
    import {ROUTER_DIRECTIVES,ROUTER_PROVIDERS} from '@angular/router-deprecated'; 
    import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router"; 
    import {AppComponent} from "./app.component"; 

    nativeScriptBootstrap(AppComponent, [ROUTER_PROVIDERS]); 

app.component.ts 
    ############ 


    import {Component} from "@angular/core"; 
import {nativeScriptBootstrap} from "nativescript-angular/application"; 
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router-deprecated'; 
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router"; 
import {FirstComponent} from "./first.component"; 
import {SecondComponent} from "./second.component"; 


@Component({ 
    selector: 'navigation-test', 
    providers: [NS_ROUTER_PROVIDERS], 
    directives: [NS_ROUTER_DIRECTIVES], 
    template: `<page-router-outlet></page-router-outlet>` 
}) 
@RouteConfig([ 
    { path: '/first', component: FirstComponent, name: 'First', useAsDefault: true }, 
    { path: '/second', component: SecondComponent, name: 'Second' }, 
]) 
export class AppComponent { } 

答えて

1

、私のコードです

、それは働いていた私は、不必要な輸入品とプロバイダを削除し、...

main.ts

import {nativeScriptBootstrap} from "nativescript-angular/application"; 
import {AppComponent} from "./app.component"; 

nativeScriptBootstrap(AppComponent); 

app.component.ts

import {Component} from "@angular/core"; 
import {RouteConfig} from '@angular/router-deprecated'; 
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router-deprecated/ns-router-deprecated"; 
import {FirstComponent} from "./first.component"; 
import {SecondComponent} from "./second.component"; 

@Component({ 
    selector: 'navigation-test', 
    directives: [NS_ROUTER_DIRECTIVES], 
    providers: [NS_ROUTER_PROVIDERS], 
    template: `<page-router-outlet></page-router-outlet>` 
}) 
@RouteConfig([ 
    { path: '/first', component: FirstComponent, name: 'First',  useAsDefault: true }, 
    { path: '/second', component: SecondComponent, name: 'Second' }, 
    ]) 
export class AppComponent { } 
+0

たTHX BRO、下記魔法のように!! @ハビカケゼミ – yeulucay

関連する問題