Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavarePart 7 - Basic of Filters in AngularJS
#1
AngurJS Filter:
[Image: tIvseWl.png]
-Filters in angularjs takes input and produces some modified output.
-The output of filter will be a formatted output or input.
-Selects a subset of items from array and returns it as a new array.
-Filters can be added in AngularJS to format data.

Filters can be used for commonly following task
1.Format data.
2.transform data.
3.search or filter data.


Filters can be used in
-views(HTML data)
-controller
-services


There are two types of filters

1.Built-in filters.
number,date uppercase,filter,lowercase orderBy etc.

2.Custom filters.
Developed by us


Syntax:
Filters can be added to expressions by using the pipe character |, followed by a filter name.


Example to use filter in html view
Code:
{{ filter_expression | filter : expression : comparator : anyPropertyKey}}


Example to use filter in javascript or in service

Code:
$filter('filter')(array, expression, comparator, anyPropertyKey)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)