I have list of student names & i want to filter names using two dates.
I have two date pickers one is for from date
another one is for to date
.if user select 2015-10-19
as from date
and 2015-10-20
as to date
, then name list should show between this two dates.
example user selected above dates
list should be
- Ramesh
- Vignesh
- Sarath
- Gomal
I have added my code below some one can help me out .
<!--begin snippet: js hide: false -->
<!--language: lang-js -->
angular.module("date", [])
.directive("datepicker", function () {
return {
restrict: "A",
link: function (scope, el, attr) {
el.datepicker({
dateFormat: 'yy-mm-dd'
});
}
};
})
.directive("datepicker1", function () {
return {
restrict: "A",
link: function (scope, el, attr) {
el.datepicker({
dateFormat: 'yy-mm-dd'
});
}
};
})
.controller("dateCtrl", function ($scope) {
$scope.names= [{
id: "1",
C_Name: "Ramesh",
C_Phone: "*******",
C_Option: {
"date": {
"$date": "2015-10-19T09:52:26.507Z"
}
}
}, {
id: "2",
C_Name: "Suresh",
C_Phone: "*****",
C_Option: {
"date": {
"$date": "2015-10-21T09:52:26.507Z"
}
}
}, {
id: "3",
C_Name: "Vignesh",
C_Phone: "*******",
C_Option: {
"date": {
"$date": "2015-10-20T09:52:26.507Z"
}
}
},
{
id: "4",
C_Name: "Sarath",
C_Phone: "******",
C_Option: {
"date": {
"$date": "2015-10-20T09:52:26.507Z"
}
}
},
{
id: "5",
C_Name: "Sundhar",
C_Phone: "******",
C_Option: {
"date": {
"$date": "2015-10-21T09:52:26.507Z"
}
}
},
{
id: "6",
C_Name: "Rajesh",
C_Phone: "******",
C_Option: {
"date": {
"$date": "2015-10-18T09:52:26.507Z"
}
}
},
{
id: "7",
C_Name: "Gomal",
C_Phone: "******",
C_Option: {
"date": {
"$date": "2015-10-20T09:52:26.507Z"
}
}
}
]
});
<!-- language: lang-html -->
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
<div ng-app="date">
<div ng-controller="dateCtrl">
<!-- jq -->
<!-- ng -->
From Date:<input type="text" datepicker ng-model="date2" />
<span>{{date2}}</span>
To Date:<input type="text" datepicker1 ng-model="date3" />
<span>{{date3}}</span>
<br><br><br>
<label>List Of Names</label>
<br>
<div ng-repeat="name in names | filter:search" >
<br>{{name.C_Name}}
<br>
</div>
</div>
</div>
<!-- end snippet -->