in my code angular put item as last elements
it is.
my controller
> $scope.init = function(){
> Publishing.query({type:'S'}, function(items) {
> $scope. items = items;
> drawCalendar(items);
> });
> };
this is a view
> <div ng-repeat="item in items | orderBy:'diffDay' | groupBy:['diffDay']
> | filter:filterDate(item)">
> <h2 ng-show="item.group_by_CHANGED">{{item.displayGroupDay}}</h2>
> <ul>
> <li>
> {{item.nomePagina}}
> <img src="{{item.imageUrl}}"/>
> {{item.text}}
> <br/>
> {{item.data}}
> </li>
> </ul>
> </div>
and this is a filter
angular.module('myApp')
> .filter('groupBy', function ($parse) {
> return function (list, group_by) {
> var filtered = [];
> var prev_item = null;
> var group_changed = false;
> // this is a new field which is added to each item where we append
> "_CHANGED"
> // to indicate a field change in the list
> //was var new_field = group_by + '_CHANGED'; - JB 12/17/2013
> var new_field = 'group_by_CHANGED';
> // loop through each item in the list
> angular.forEach(list, function (item) {
> group_changed = false;
> // if not the first item
> if (prev_item !== null) {
> // check if any of the group by field changed
>
> //force group_by into Array
> group_by = angular.isArray(group_by) ? group_by :
> [group_by];
>
> //check each group by parameter
> for (var i = 0, len = group_by.length; i < len; i++) {
> if ($parse(group_by[i])(prev_item) !==
> $parse(group_by[i])(item)) {
> group_changed = true;
> }
> }
>
> }// otherwise we have the first item in the list which is new
> else {
> group_changed = true;
> }
> if (group_changed) {
> item[new_field] = true;
> } else {
> item[new_field] = false;
> }
> filtered.push(item);
> prev_item = item;
> });
> return filtered;
> };
> });
Are there some error?
Il giorno giovedì 20 marzo 2014 12:33:09 UTC+1, Lorenzo Bugiani ha scritto:
>
> I haven't understand: what it the problem?
> Every time items change, it will be re evaluated in ng-repeat.....
>
>
> 2014-03-20 10:36 GMT+01:00 Silvio Troia <[email protected] <javascript:>
> >:
>
>> Is't possible to re-render a ng-repeat list item to applicate a filter?
>>
>> if i push a item, angular put it as last element, without order it.
>>
>> <div ng-repeat="item in items | orderBy:'diffDay' | groupBy:['diffDay']
>>> | filter:filterDate(item)">
>>
>>
>> and in controller
>>
>> Publishing.save({}, function(item) {
>>> $scope.items.push(item);
>>> });
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "AngularJS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.