Tag Archives: limitTo

AngularJS – Filters(1)

By adding filters, you could get a write form to express a data.

In AngularJS, we use ‘|’, a pipeline for combining a data with filter.

 

currency

  • ${{data.price | currency}}
  • currency filter automatically do the job for localisation.
  • output (assuming we are in the U.S)
    $10.00

 

date

  • {{date_expression | date}}
  • example
    {{‘1388123412323′ | date:’MM/dd/yyyy @ h:mma’}}
  • output
    12/27/2013 @ 12:50AM

uppercase

  • {{‘octagon gem’ | uppercase}
    => OCTAGON GEM

 

limitTo

  • {{‘My Description’ | limitTo:8}}
    => My Descr
  • limitTo filter can be found even in ‘ng-repeat’ directive to limit the iteration.

orderBy

  • <li ng-repeat=”……. | orderBy:'(-)which'”>
  • order the repeating items in descending order if including ‘- (minus)’, or ascending order if not including it.