2017-07-07 49 views
1

我有使用角2與.NET的WebAPI申請,並決定升級到角4如何判斷我的應用是否從角度2升級到角度4是否成功?

我通過像在cmd爲我的項目目錄中的下列財產以後去(連同安裝缺少的幾次迭代依賴):

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 

我最近通過CLI去更新我從角2角應用角度4.現在,有沒有辦法,我確認我的應用程序使用實際的角度4,而不是2?

如果我輸入「NG --version」成有我的項目直接CMD線,然後我得到以下結果:

@angular/cli: 1.2.0 
node: 6.10.2 
os: win32 x64 
@angular/animations: 4.2.5 
@angular/common: 4.2.5 
@angular/compiler: 4.2.5 
@angular/compiler-cli: 4.2.5 
@angular/core: 4.2.5 
@angular/forms: 4.2.5 
@angular/http: 4.2.5 
@angular/platform-browser: 4.2.5 
@angular/platform-browser-dynamic: 4.2.5 
@angular/platform-server: 4.2.5 
@angular/router: 4.2.5 
@angular/cli: 1.2.0 

,如果我跑我的應用程序,然後和看布勞爾開發工具我看到這個在DOM資源管理器:

<html> 
<body> 
    <my-app ng-version="2.4.8" _nghost-vrp-0=""> 
... other stuff that isn't important 
</html> 
</body> 

所以它看起來像我的應用程序說NG版=「2.4.8」但我CLI說不同?我是否成功升級,如果是的話,瀏覽器開發人員工具中的DOM爲什麼會有不同的說法?

同樣,這是一個.NET WebAPI應用程序,它正在使用angular 2。

回答

1

你總是可以嘗試一些新的熱點angular4功能,看看它是否工作,或者看它是否有NG構建--prod編譯--aot

<div *ngIf="userList | async as users; else loading"> 
    <user-profile *ngFor="let user of users; count as count; index as i" [user]="user"> 
User {{i}} of {{count}} 
    </user-profile> 
</div> 
<ng-template #loading>Loading...</ng-template> 
+0

是代碼應該原樣在HTML中沒有添加到組件?它不起作用:未處理的承諾拒絕:模板解析錯誤: 無法綁定到'用戶',因爲它不是'用戶配置文件'的已知屬性... 即時猜測意味着我沒有角4在應用程序? –

+0

您需要綁定到ts文件的正確對象。這只是示例角度給出的關於ngIfs和ngFors的新語法 – Surreal

+0

您是否有該文檔的鏈接?我想通過它,並嘗試您的建議 –

0

原來我的應用程序升級到這是一個不清除我的緩存的問題,所以它顯示爲2.x而不是4.x.現在它正確地顯示了正確的版本和Angular 4語法正常工作。