angular.js
angular.js copied to clipboard
ng-repeat doesn't work when window resize
It may be a bug or me wrong something? Here's an example: Controller:
self.arr = [{
'n': 1
}, {
'n': 2
}];
self.add = function () {
self.arr.push({
'n': self.arr.length + 1
});
};
var f = true;
$(window).resize(function () {
if (f) {
f = false;
setTimeout(function() {
{
self.add();
}
}, 2000);
}
});
View:
<p ng-repeat="it in vm.arr">{{it.n}}</p>
<button ng-click="vm.add()">add</button>
when I resize window 'arr' is expanded but ng-repeat doesn't work. I click button ng-repeat it works and show all array
Hi, this is actually working as expected. You need to call scope.$digest() or scope.$apply() in your event handler, in order for the view to update
Thank you. It work :+1:
I have an another issue :( ng-style can bind but it don't effect to style.
<div ng-style="{'left':'703px', 'top':'-11px'}" style="left: 703px; top: -11px;"></div>
when window resize:
<div ng-repeat="com in vm.comments" ng-style="{'left':'525px', 'top':'-11px'}" style="left: 703px; top: -11px;"></div>