I have a directive with two divs:
<div id="childContainer">
<div id="child">
<a class="btn btn-primary testBtn1" ng-show="!vm.hideButton">Test Button 1</a>
<a class="btn btn-secondary testBtn2">Test Button 2</a>
</div>
</div>
I'm trying to keep the childContainer div the same height as the child div, specifically when I hide testBtn1. Here's the watch function inside my directive's controller which should do that:
$scope.$watch(function(){
return vm.child.height(); //vm.child is a jQuery object
}, function(){
vm.childContainer.height(vm.child.height()); //vm.childContainer is a jQuery object
});
However, this isn't working as expected. It's as if the watch function triggers too late. You can view the issue here on my plnkr.
$scope.$watch('vm.child.height', function(){ vm.childContainer.height(vm.child.height()); }).$watchdoesn't work that way. You put a watch on a variable, not a value.