Hi all,is it possible reload (re-render) ng-repeat list items if I push another item to list (array)?
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/JcZeAUaCY2sJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Welcome to the beauty of angular: It automatically re-renders itself when the underlying array is changed.
Pete
On 4 April 2012 18:04, Patrik Votoček <pat...@votocek.cz> wrote:
Hi all,is it possible reload (re-render) ng-repeat list items if I push another item to list (array)?
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/JcZeAUaCY2sJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/Jz7IGLcYpsMJ.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
<div ng-repeat="item in items | orderBy:'diffDay' | groupBy:['diffDay'] | filter:filterDate(item)">
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 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.
$scope.init = function(){
Publishing.query({type:'S'}, function(items) {
$scope. items = items;
drawCalendar(items);
});
};
<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>
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;
};
});