如何判断我的应用是否从角度2升级到角度4是否成功?
问题描述:
我有使用角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。
答
你总是可以尝试一些新的热点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>
答
原来我的应用程序升级到这是一个不清除我的缓存的问题,所以它显示为2.x而不是4.x.现在它正确地显示了正确的版本和Angular 4语法正常工作。
是代码应该原样在HTML中没有添加到组件?它不起作用:未处理的承诺拒绝:模板解析错误: 无法绑定到'用户',因为它不是'用户配置文件'的已知属性... 即时猜测意味着我没有角4在应用程序? –
您需要绑定到ts文件的正确对象。这只是示例角度给出的关于ngIfs和ngFors的新语法 – Surreal
您是否有该文档的链接?我想通过它,并尝试您的建议 –