Wednesday, July 1, 2015

Filtering in Angular Js

This is also a sample from the reference source "AngularJs Fundamentals in 60- ish minutes"  in https://www.youtube.com/watch?v=i9MHigUZKEM

We can do filter using "filter and '|' "
Following example is to filter from group of customers using using the customer name or city name typed in the text box.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app ="">
<head>
    <title>Using AngularJs directives and data binding</title>
</head>
<body data-ng-init ="customers=[{name:'John Smith',city:'Phoneix'},{name:'John Doe', city:'New York'},{name:'John Doe', city:'San Francisco'}]">
    Name:
    <br />
    <input type="text" data-ng-model ="name" /> {{name}}
    <br/>
    <ul>
        <li data-ng-repeat ="cust in customers | filter: name">{{cust.name}} - {{cust.city}}</li>
    </ul>

    <script src="Scripts/angular.min.js"></script>
</body>
</html>