2016-08-29 104 views
2

我收到此錯誤,當我更新到nativescript-angular的最後一個版本時,我想這個問題與我使用的版本Angular 2和模塊使用的版本有所不同。有人能告訴我什麼是我應該使用的正確版本來使它工作? 請注意,我打算升級到nativescript-angular的最後一個版本是使用RouterExtensions角度2:類型'Route []'的參數不能分配給類型'Route []'的參數。

Argument of type 'Route[]' is not assignable to parameter of type 'Route[]'. 
    Type 'Route' is not assignable to type 'Route'. 
    Types of property 'pathMatch' are incompatible. 
     Type 'string' is not assignable to type '"full" | "prefix"'. 
     Type 'string' is not assignable to type '"prefix"'. 
const routes: Route[] 

這些都是我的package.json依賴關係:

"dependencies": { 
    "@angular/common": "2.0.0-rc.4", 
    "@angular/compiler": "2.0.0-rc.4", 
    "@angular/core": "2.0.0-rc.4", 
    "@angular/forms": "0.3.0", 
    "@angular/http": "2.0.0-rc.4", 
    "@angular/platform-browser": "2.0.0-rc.4", 
    "@angular/platform-browser-dynamic": "2.0.0-rc.4", 
    "@angular/platform-server": "2.0.0-rc.4", 
    "@angular/router": "^3.0.0-rc.1", 
    "@angular/router-deprecated": "2.0.0-rc.2", 
    "@angular/upgrade": "2.0.0-rc.4", 
    "nativescript-angular": "^0.3.1", 
    "nativescript-plugin-firebase": "^3.5.3", 
    "reflect-metadata": "^0.1.8", 
    "rxjs": "5.0.0-beta.6", 
    "tns-core-modules": "^2.3.0-2016-08-29-3966", 
    "zone.js": "^0.6.17" 
    }, 

的app.routes.ts:

import { RouterConfig } from '@angular/router'; 
import { nsProvideRouter} from 'nativescript-angular/router'; 
import { LoginComponent } from './components/login.component'; 
import { DashboardComponent } from './components/dashboard.component'; 


const routes: RouterConfig = [ 
    { 
     path: '', 
     redirectTo: '/login', 
     terminal: true 
    }, 
    { 
     path: 'login', 
     component: LoginComponent 
    }, 
    { 
     path: 'dashboard', 
     component: DashboardComponent 
    } 
]; 


export const APP_ROUTER_PROVIDERS = [ 
    nsProvideRouter(routes, { enableTracing: false }) 
]; 
+0

聽起來像你正在從2個不同的包中導入'Route'。 –

回答

2

似乎有是沒有通過@angular/router出口財產RouterConfig。請嘗試使用Routes代替。

const routes: Routes = [ // <== 
    { 
     path: '', 
     redirectTo: '/login', 
     terminal: true 
    }, 
    { 
     path: 'login', 
     component: LoginComponent 
    }, 
    { 
     path: 'dashboard', 
     component: DashboardComponent 
    } 
]; 
+1

我犯了一個拼寫錯誤,我寫了Route而不是Routes,並得到了同樣的錯誤。感謝回答所做的更改併發揮作用。 – heman123

2

我有同樣的問題,但問題的根源是,包我使用與角2和項目與角4內置雖然,包版本內置工作2+問題在於該方法期望使用舊的(ng2)路線,但卻使用了新的(ng4)路線。 顯然有區別。

我的解決方案是刪除類型定義爲通過我的路線任何類型。

相關問題