Tuesday, April 21, 2015

AngularJs filter data by user input

<html>
<title> AngularJs Directives </title>

<body>

<div ng-app="" ng-controller="firstController">

Enter subject: <input type="text" ng-model="Subject">

<ol>
<li ng-repeat="item in data | filter : Subject">

{{ item.Subject + ' ' + item.marks }}

</li>
</ol>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>

<script>


function firstController($scope)
{

$scope.data=[
{
Subject:'English',marks:'40'
},
{
Subject:'Math',marks:'50'
},
{
Subject:'History',marks:'60'
},
{
Subject:'chemistry',marks:'70'
},
{
Subject:'Biology',marks:'45'
}
];
}

</script>

</body>
</html>

No comments:

Post a Comment