Questions tagged getelementbyid

Explore the latest questions and answers asked by our top developers.

Read value of an html script element in Angular, which is of type json

In the html page, there will be a script element which is a static content ( generated from a Django backend) with an ID. <script id="hello-data" type="application/json">{"hello": "worldu003C/scriptu003Eu0026amp;"}</script> I wanted to get that data in an angular service ( or even component) which would have a simple getElementById is javascript. const value = JSON.parse(document.getElementById(‘hello-data’).textContent); I […]

By A J
Categorized as angular, django, getelementbyid, javascript Tagged , , ,

Check elementById inside a particular div/Angular Component

Actually I was looking a way of getting DOM Element inside a component, like right now , I am using document.getElementByID() to get the reference of that particular element and it returns the first element in the whole document that matches the id. But I want that it should return the first matching element from […]

By Tanishka Bansal
Categorized as angular, dom, getelementbyid Tagged , ,

Cannot read property ‘getBoundingClientRect’ of null in Angular

I am trying to get px height of this <div class="bundles-wrap enterprise" element using getBoundingClientRect().height or this.elementView.nativeElement.offsetHeight. This is my html <div class="row d-flex align-items-end" *ngFor="let value of valueList"> <!– start–> <div class="bundles-wrap enterprise" id="card-id" #card> <div class="hdr"> <h2>{{value.Name}}</h2> <span>What you’ll get</span> </div> </div> </div> This is my component class. valueList: Model[]; @ViewChild(‘card’, {read: ElementRef, […]

Can I get leaflet map object through dom getElementByID()?

I’m using Angular 7 and I need to set a marker on map which is in entirely different component, is it possible to access the leaflet object throught DOM and make changes to it? I don’t want to make any major changes to the existing map component. Thanks! Source: Angular Questions

By Vamshi
Categorized as angular, dom, getelementbyid, leaflet Tagged , , ,

DOM manipulation from javascript to Angular Typescript

I’m doing angular project. I built a button and want to apply document.getElementById(‘b3m’).addEventListener but it return an error Object is possibly ‘null’. I think there is difference between syntax javascript and typescript for DOM manipulation. I found a solution (see below) but I think there is another way. Can you guys help me? Thanks in […]

Angular Directive, Match Height of ElementId

In the DOM I have 2 elements side by side. I want the right-element to always have the same height as the left-element. The right element may have more content than the left and will have a scrollbar in that scenario. (otherwise this could be achieved with flexbox) I have achieved this by creating a […]

By Carlos Magno Rosa
Categorized as angular, directive, getelementbyid Tagged , ,

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us