我想用jQuery访问ng-repeat指令中的div,但问题是我得到了undefined。当我删除ng-repeat指令时它工作正常。有没有解决方法呢?
以下是代码:
<div id="showAdmins" ng-show="showAdmins">
<div class="card card-block" ng-repeat="admin in showAdmins track by $index" style="float: left;margin: 30px; background: #fff;">
<h3 class="card-title">{{admin}}</h3>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<button class="btn btn-primary" ng-click="searchAdmins(admin)">See Profile</button>
</div>
和控制器:
(function(){
var cardBox = $('.card.card-block');
console.log(cardBox[0]);
for(var i=0; i<cardBox.length;i++){
cardBox[i].style.padding = '15px';
}
})();
答案 0 :(得分:1)
使用ng-style,因为我没有看到在你的代码中使用jQuery的任何情况!