Я новичок в angularJS и пытаюсь найти высоту дочернего div из родительского div.I хочу сделать это без jquery. Я попробовал много решений отсюда, но не из них работал на меня.set высота ребенка div в AngularJS
У меня есть еще одно сомнение: в jquery мы можем использовать $ (". Class"). Height() и $ (". Class"). Css ("value"), как этот angularJS предоставляет любую возможность установить свойства родительского и дочернего div.
здесь я использую понятие директивы, чтобы установить эти вещи,
Код
myApp.directive('orientable', function() {
return {
restrict: 'A',
link: function(scope, element, attrs, controller) {
//this both will work fine
alert(element.children()[0].offsetHeight);
alert(element.children()[1].offsetHeight);
debugger;
element.children()[0].height();
//Uncaught TypeError: element.children(...)[0].height is not a function(…)
//this bellow code is showing the error
element.children()[0].css('height','250px');
//Uncaught TypeError: element.children(...)[0].css is not a function(…)
}
}
});
<div orientable class=main ng-app="myApp">
<div class=ele1> </div>
<div class=ele2> </div>
<div class=ele3> </div>
</div>
который (клиентHeight or offsetHeight) равен .hight() jquery – user3501613