Skip to content

Instantly share code, notes, and snippets.

@chekit
Last active September 26, 2017 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chekit/054ae750c6d7225772186fbcd5201b41 to your computer and use it in GitHub Desktop.
Save chekit/054ae750c6d7225772186fbcd5201b41 to your computer and use it in GitHub Desktop.
replace AngularJS expressions with Angular expressions

*ngFor

Заменяет старый синтаксис ng-repeat="item in obj.items track by $index" или ng-repeat="item in items track by $index" на новый *ngFor="let item of obj.items; trackBy: trackById;" или *ngFor="let item of items; trackBy: trackById;"

Выражение:

ng-repeat="([a-zA-Z]*)\s+(in)\s+([a-zA-Z\.{1}().]*)\s+track by \$index"

Замена:

*ngFor="let $1 of $3; trackBy: trackById;"

Пример: http://jsbin.com/wiruqe/edit?js,console, https://regex101.com/r/T9ufcA/4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment