I'm building a filter AngularJS, to display only data that contains the current date in the query, at the moment I'm doing this, but I can not get it to work.
-J_Wjq2vkPJxCkmk3Wxp
Estado: "pendiente"
FechaActividad: "2014-11-11"
NombreActividad: "Actividad 1"
-J_WrCwULkPGRD5-mZ6z
Estado: "aprobado"
FechaActividad: "2014-10-11"
NombreActividad: "Actividad 2"This is the filter I try to build to build
app.filter('fechas', function($filter)
{
return function(input)
{
if(input == null){ return ""; }
var _date = $filter('date')(new Date(input), 'MMM dd yyyy');
return _date.toUpperCase();
};
});and so I am showing my html.
<div ng-repeat="i in list | date">
<span>{{i.Estado}}</span>
<span>{{i.FechaActividad}}</span>
<span>{{i.NombreActividad}}</span>
</div>also try to do the following but neither had resulted
<div ng-repeat="i in list | fechas:['FechaActividad']">Filter, which you tried to build will not serve the purpose.
In this case, your filter must return a boolean, which will select the record in ng-repeat to be displayed.Solution to your problem can be addressed in the following way:
1. Create a variable dt in $scope within controller as:$scope.dt = $filter('date')(new Date(), 'yyyy-MM-dd');2. Change the HTML fragment as:
<div ng-repeat="i in data | filter: {FechaActividad: dt}">
<span>{{i.Estado}}</span><br/>
<span>{{i.FechaActividad}}</span><br/>
<span>{{i.NombreActividad}}</span><br/>
<hr/>
</div>
Hope this resolves the problem.--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/qj6PdqnmsWQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
![]() | Luis Ruiz F. Tu Chillan
|