

Angularjs Filter JSON Object to Show / Hide / Update Elements based on Conditions

Jul 16, 2015

Here I will explain how to use
AngularJS to filter JSON object to show or hide or update elements with example or AngularJS filter json object in controller with example. By using filter option in ng-repeat we can enable/disable or show/hide required elements from JSON object.

In previous articles I explained
Angularjs ui grid cell template click event, bind dropdownlist in angularjs, Angularjs convert lower case to upper case while typing text, Angularjs refresh div for every 1 second using interval mode and many articles relating to AngularJS, jQuery, JavaScript and Now I will explain how to filter JSON object to change elements behavior in using AngularJS.

To show or hide values based on JSON object in AngularJS we need to write the code like as shown below

$scope.checkvalues = function (user) {
return != "5";

If you want to check it in complete example you need to write the code like as shown below

<html xmlns="">
<title>angularjs filter json object to show/hide or update elements</title>
<script src=""></script>
<script type="text/javascript">
var app = angular.module('sampleapp', [])
app.controller('samplecontrol', function ($scope) {
$scope.sample = [{
id: '1',
name: 'Suresh Dasari'
}, {
id: '2',
name: 'Rohini Alavala'
}, {
id: '3',
name: 'Mahendra Dasari'
}, {
id: '4',
name: 'Madhav Sai'
}, {
id: '5',
name: 'Mahesh Dasari'
}, {
id: '6',
name: 'Sateesh Alavala'

$scope.checkvalues = function (user) {
return != "5";
<body data-ng-app="sampleapp" data-ng-controller="samplecontrol">
<form id="form1">
<div ng-repeat="user in sample | filter:checkvalues">
{{}} <br/>


If you check below output it will display all values except id = 5



subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

Hey than'x buddy , it's useful for me!!!

Give your Valuable Comments


© 2015 All Rights Reserved.