My first experiment with angular.js.
I've a few columns, each of them includes some template:
<div class="col-md-5 js-column" ng-repeat="orm in orms" repeat-done="equalHeight">
<h2>{{ orm.name }}</h2>
<ng-include src="'/inc/_compiled/'+orm.id+'.html'"></ng-include>
</div>
Each included template contains the same elements as other templates, but they've different height. Example element:
<pre data-task="model" class="task-model">
from django.db import models
class Teacher(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
</pre>
The thing I want to achieve is to set equal height for specific element in all the columns. That means all pre.task-model
will have the same height.
I've created some directive and the idea was to trigger it after ngRepeat
loop is finished (scope.$last
). But when I try to access the included nodes via jQuery/DOM selectors, I get nothing. I know each template is available in element
variable, but I need to get also the other columns.
var ormApp = angular
.module('ormApp', [])
.directive('repeatDone', function () {
return function (scope, element, attrs) {
if (scope.$last) {
$('.js-column pre.task-model'); //<- got nothing
}
};
})