I want to grab an element by his class with JQuery, but for some reason that's not working. The length of the JQuery object is 0, and that's happening only, if I want the class that is inside the element with ng-repeat
.
index.html
<body ng-controller="MainCtrl">
<div user>
<div ng-repeat="user in users" class="user">
<p>{{user.name}}</p>
</div>
</div>
</body>
app.js
app.controller('MainCtrl', function($scope) {
$scope.users = [{name: 'name1'}, {name: 'name2'}];
});
.directive('user', function() {
return function(scope, ele) {
console.log('Im here');
console.log($('.user')); // this is not working the length is 0
}
})