Live Editable Example:
JS
HTML
JS
angular.module('FilterInControllerModule', []).
controller('FilterController', ['$scope', 'filterFilter',
function($scope, filterFilter) {
$scope.EntryName = '';
$scope.array = [{
name: 'Tobias'
}, {
name: 'Jeff'
}, {
name: 'Brian'
}, {
name: 'Igor'
}, {
name: 'James'
}, {
name: 'Brad'
}];
$scope.$watch('EntryName', function() {
$scope.filteredArray = filterFilter($scope.array, {
name: $scope.EntryName
});
}, true);
}
]);
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example96-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.3/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="FilterInControllerModule">
<div ng-controller="FilterController">
<div>
Filter by :
<input type="text" ng-model="EntryName">
</div>
All entries:
<span ng-repeat="entry in array">{{entry.name}} </span>
<div>
Filter By Name in angular controller
<span ng-repeat="entry in filteredArray">{{entry.name}} </span>
</div>
</div>
</body>
</html>
No comments:
Post a Comment