2017-07-19 45 views
1

我試圖通過旅遊網站上angular.io學習英雄的角2,現在我拿到卡在路由器的方法>> ParamMap,我添加一行:角2 ParamMap

import { ActivatedRoute, ParamMap } from '@angular/router';

但是編譯器顯示錯誤「模塊‘路徑......’沒有出口成員‘ParamMap’」

我建我通過角CLI項目。

文件的package.json

@angular/router": "^3.3.1"

我搜索文件夾@角/路由器/ src目錄/ index.d.ts出口ParamMap但我沒找到,到API但該網站說路徑:路由器/ src/shared.ts但我也沒有找到這個類。 我建議這個班級在新版本中刪除,反之亦然,在新版本的角色4中添加。 我該如何解決這個錯誤?

回答

0

對於任何人遇到此問題,以下是如何將您的Angular版本從2或3升級到npm中的最新版本。

在Unix

npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest [email protected] --save 

在Windows

npm install @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] [email protected] --save 

解決方案在這裏找到:https://progblog.io/How-to-upgrade-to-Angular-4/

0

我解決了這個問題,我重新安裝了angular-cli後,我比我刪除node_modules文件夾在我的項目後,比我更改我的package.json與新的依賴關係(angular4等)後比安裝所有依賴和運行服務器,後我沒有得到錯誤。