Skip to content

Instantly share code, notes, and snippets.

@chekit
Created July 12, 2016 10:05
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/4d7514fc28d40a4c1c85a2cf7773fee3 to your computer and use it in GitHub Desktop.
Save chekit/4d7514fc28d40a4c1c85a2cf7773fee3 to your computer and use it in GitHub Desktop.
Переиспользования результата фильтрации списка элементов
.regions
.regions__item(
ng-repeat="region in mobnav.regions",
ng-hide = "filteredLocations.length === 0"
)
h2.regions__item-header {{region.name}}
ul.cities
li.cities__item(
ng-repeat="location in (filteredLocations = (region.cities | filter: filterRegion))"
)
span.cities__item-name(ng-click="mobnav.setRegion(location)") {{location.name}}
@chekit
Copy link
Author

chekit commented Jul 12, 2016

Кратко: ng-repeat="location in (filteredLocations = (region.cities | filter: filterRegion))" и теперь в нашем $scope есть переменная filteredLocations, которая содержит результат работы фильтра AngularJS

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