Angular 1.x 升级到 Angular 2

原项目用ng1.5写的,现在改成ng2.0了,踩了不少坑,不过都忘记了。

如果你也正好要做这个工作,正好看到这个文章,不妨参考下。

 

AngularJs 1.x -> 2.0

ng-repeat -> *ngFor
ng-show -> *ngIf   [hidden]   [style.display]=""
ng-class -> [ngClass]
ng-if -> *ngIf
ng-model -> [(ngModel)] + name=''
ng-click -> (click)
ui-sref -> routerLink="../{{p.ID}}"
myattr='x' -> attr.myattr='x'

另,<script>不再支持了,用System.Import(),我没试过。

 

posted @ 2016-11-15 18:26  heguo  阅读(1005)  评论(0编辑  收藏  举报