【发布时间】:2012-08-07 19:27:27
【问题描述】:
我正在尝试使用 angular 加载 div 以提供给同位素进行布局。出于某种原因,我不能使用 ng-repeat 来创建 div。当我做类似的事情时,它工作正常:
[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"
}]
}]);
虽然上述工作正常,但当我尝试从 Angular 使用 ng-repeat 时,div 似乎变得不可见(它们在 dom 中,但我看不到它们)。我试过调用 isotope('reloadItems') 和 isotope('reLayout'),但似乎没有帮助。
[agg.html]
<div class="mygrid" iso-grid ng-repeat="card in cards">
<div class="item">myitem</div>
</div>
如何使用 ng-repeat ?
【问题讨论】:
-
为了避免此类问题,我写了一个原生 AngularJS 等价于 jQuery isotope,随意看看:tristanguigue.github.io/angular-dynamic-layout
标签: jquery angularjs jquery-isotope