You search using Name textbox on both view1 and view2.
Route.html
<!DOCTYPE html>
<html >
<head >
<title>Factory</title>
</head>
<body data-ng-app="myApp">
<div >
<ul class="nav">
<li>
<a href="#View11"> view1 </a>
</li>
<li>
<a href="#View22"> view2 </a>
</li>
</ul>
<!-- placeholder forview -->
<div data-ng-view=""></div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script>
var demoApp = angular.module('myApp', []);
//Routing
demoApp.config(['$routeProvider',
function ($routeProvider)
{
$routeProvider.
when('/View11',
{
templateUrl: 'View1.html',
controller: 'SimpleController'
}).
when('/View22',
{
templateUrl: 'View2.html',
controller: 'SimpleController'
}).
otherwise({
redirectTo: '/View11'
});
}]);
//Controller
demoApp.controller('SimpleController', function ($scope)
{
$scope.customers = [
{ name: 'jahanzaib', city: 'Lahore' },
{ name: 'Aslam', city: 'Faislabad' },
{ name: 'Ali', city: 'Karachi' }
];
$scope.addCustomer = function ()
{
$scope.customers.push(
{
name: $scope.newCustomer.name,
city: $scope.newCustomer.city
});
};
});
</script>
</body>
</html>View1.html
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1>View1</h1>
Name:
<br />
<input type="text" data-ng-model="name"/>
<br />
<ul>
<li data-ng-repeat="cust in customers">{{cust.name | uppercase}} - {{cust.city}}</li>
</ul>
</body>
</html>View2.html
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1>View2</h1>
Name:
<br />
<input type="text" data-ng-model="name"/>
<br />
<ul>
<li data-ng-repeat="cust in customers| filter : name">{{cust.name | uppercase}} - {{cust.city}}</li>
</ul>
<br />
Customer name :
<input type="text" data-ng-model="newCustomer.name"/>
<br />
Customer City:
<input type="text" data-ng-model="newCustomer.city"/>
<br />
<button data-ng-click="addCustomer()">Add Customer</button>
</body>
</html>