如何判断我的应用程序从角度2升级到角度4是否成功?

时间:2017-07-07 16:56:08

标签: .net angular asp.net-web-api npm

我有一个使用角度2的.NET WebAPI应用程序,并决定升级到角度4。

我在我的项目目录的cmd中经历了类似下面的内容(以及安装缺少的依赖项的几次迭代):

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --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-version =&#34; 2.4.8&#34;但我的CLI说的有何不同?我是否成功升级,如果是这样,为什么浏览器开发人员工具中的DOM会有不同的说法?

同样,这是一个使用角度为2的.NET WebAPI应用程序。

2 个答案:

答案 0 :(得分:1)

你总是可以尝试一些热门的新角度4功能,看看它是否有效,或者看看它是否用ng build编译--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>

答案 1 :(得分:0)

原来我的应用程序升级为角度4.这是一个不清除缓存的问题,所以它显示为2.x而不是4.x.现在它正确显示正确的版本,Angular 4语法工作正常。