I'm trying to use angular to load div's to supply to isotope for layouting. For some reason, I can't use ng-repeat to create the div's. When I do something like, it works fine:
[agg.html]
<div class="mygrid" iso-grid>
<div class="item">myitem</div>
</div>
[controlers.js]
module.directive('isoGrid', function () {
return function (scope, element, attrs) {
element.isotope({
itemSelector: '.item'
});
};
});
module.controller('aggViewport', ['$scope', '$location', function ($scope, $location) {
$scope.cards = [{
"ID": "myid",
"class": "cardListTile",
"badge": "1"
} {
"ID": "myid2",
"class": "cardListTile",
"badge": "2"
}]
}]);
While the above works ok, when I try to use ng-repeat from angular, the div's seem to become invisible (they are in the dom, but I can't see them). I've tried calling isotope('reloadItems') and isotope('reLayout'), but it doesn't seem to help.
[agg.html]
<div class="mygrid" iso-grid ng-repeat="card in cards">
<div class="item">myitem</div>
</div>
How can I use ng-repeat ?
Try $watching the list variable (cards), and whenever it changes re-apply the isotope. I think your problem is isotope is running before the ng-repeat is filled in.
Quick example:
scope.$watch(attrs.ngModel, function() {
elm.isotope();
});