Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax for ng-repeat angular directive and pipe character

I am studying the angularJS home page samples and I came across the following usage of the angularJS ng-repeat directive:

 <tr ng-repeat="project in projects | filter:search | orderBy:'name'">

Is the pipe character an angularJS keyword or a plain JS keyword? Also, what is the desired effect of this keyword?

like image 588
balteo Avatar asked Mar 05 '13 12:03

balteo


2 Answers

The pipe character has special meaning in AngularJS expression language and is used to invoke filters.

In short: this is AngularJS keyword to invoke filters.

like image 177
pkozlowski.opensource Avatar answered Oct 31 '22 22:10

pkozlowski.opensource


It's an Angular keyword/symbol which is used when you want to apply some Angular filter to the input. In this case you may read the expression as follows:

  1. Take projects collection,
  2. Apply search filter on it,
  3. Than take the result of the search filter and apply the orderBy filter on it,
  4. Than take the result of the orderBy filter and feed it to ng-repeat
like image 44
Stewie Avatar answered Oct 31 '22 22:10

Stewie