The objective of the code is to:
- Get the height of my section
- Set the height of my Object
The current .js code is:
app.directive('safety', function() {
return {
restrict: 'A',
link: function(scope, element) {
var section = element[0].offsetHeight;
var padding = 60;
var heading = 49;
var button = 74;
var margin = padding + heading + button;
var newHeight = section - margin;
console.log('Section: ' + section);
console.log('New height: ' + newHeight);
}
};
});
My HTML is:
<section class="section container-fluid safety-container" safety>
<h1 class="page-header">Procedures</h1>
<div class="row">
<div class="impact-doc-link col-md-12">
<a class="btn btn-safety btn-block" href="doc/procedures.pdf" role="button">Procedures</a>
</div>
<div class="impact-pdf-container col-md-12">
<object data="doc/procedures.pdf" type="application/pdf" width="100%" height="100%">
alt : <a href="doc/procedures.pdf">doc/procedures.pdf</a>
</object>
</div>
</div>
</section>
How can I set the height of the ".impact-pdf-container" to the newHeightVariable from within the 'safety' directive? I'm quite new to angular js. Do I make a new directive? Or can I simply append the directive to incorporate this functionality.
Another thing is instead of me using the variables 'padding' and 'heading' how can I get other element heights from within the directive?