Answer the question
In order to leave comments, you need to log in
How to bind the height of an element to the height of another element in Angular JS?
As I understand it, you can directly bind the height of one element to the height of the second only through the use of the directive. I would like to bind to the window resize and document ready events, but so far it has not worked out, I tried this:
.directive('bindToHeight', function ($window) {
return {
restrict: 'A',
link: function (scope, elem, attrs) {
var attributes = scope.$eval(attrs['bindToHeight']);
var targetElem = angular.element(document.querySelector(attributes[1]));
// Watch for changes
scope.$watch(function () {
return targetElem.height();
},
function (newValue, oldValue) {
if (newValue != oldValue) {
elem.css(attributes[0], newValue);
}
});
}
};
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question