Monday, 1 September 2014

AngularJS Filter on JSON object fields and entire object

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
       pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="Script/angular.min.js"></script>
<script>
      
</script>
<title>AngularJS Demo</title>
</head>
<body ng-app>
       <h2>My Contact</h2>
       <div
              ng-init="contacts = [{name:'Moin', phone:'123423424'},
                         {name:'Neamat', phone:'12312313'},
                         {name:'Reha', phone:'87897987'}]">

              On All Object <input ng-model="search.$"> <br> On Name Field <input
                     ng-model="search.name"><br> On Phone Field <input
                     ng-model="search.phone"><br>
                     <hr>
              <div ng-repeat="contact in contacts | filter:search:strict">{{contact.name}}
                     - {{contact.phone}}</div>
</body>

</html>

_________________________________________________________________________

output


No comments:

Post a Comment