Search example
Showing posts with label filter. Show all posts
Showing posts with label filter. Show all posts

Filter by and operator in AngularJs

In this post I will show you how to use && operator in AngularJs.
Example I have a students list as below:

 $scope.students = [  
       { name: 'Hai', age: 25, gender: 'boy' },  
       { name: 'Hai', age: 30, gender: 'girl' },  
       { name: 'Ho', age: 25, gender: 'boy' },  
       { name: 'Hoan', age: 40, gender: 'girl' },  
       { name: 'Hieu', age: 25, gender: 'boy' }  
     ];  

I want to filter students via gender to be boy and filter by name of them.

The first I create a function named "filterbyboy" as following:

 $scope.filterbyboy = function (genderstr) {  
       if ((typeof $scope.search === 'undefined')||($scope.search === ''))  
         return (genderstr = "")  
       else  
        return (genderstr = "boy");  
     };  

Explaination: if not filter name then display all students else filter by input name and gender as 'boy'

Here is full HTMLcode

Angularjs table sorting filter and paging

Angularjs table sorting, filter and paging

This post provides an example about how create a table via sorting, filter and paging. Following directives and services in angularjs will be used:
  • orderby
  • filter
  • ng-click
  • ng-model
  • ng-repeat

Angularjs table via sorting and filter on columns example

Angularjs table example

 This post provides an example about how create a table via sort and filter features.
Following directives and services in angularjs will be used:
  • orderby
  • filter
  • ng-click
  • ng-model
  • ng-repeat
  • ng-init



Popular Posts