Angular get offset top of element. Jul 24, 2012 · I did it like this in Internet Explorer.

New dog listed for rescue at the Saving and Rehoming Strays - Bentley

Angular get offset top of element. getBoundingClientRect().

Angular get offset top of element right, rect. top, rect. If there is no positioned ancestor element, the body is returned. getBoundingClientRect(); console. top; const elementRect = element. Template: &lt;div #divHandle *ngF. If the document is not the active Sep 27, 2018 · Otherwise, when "X. Angular elements. offsetTop) { this Configures the top offset used when scrolling to an anchor. offset() to get the offset compared to the document element and then use the scrollTop property of the window element to find how far down the page the user has scrolled: var scrollTop = $(window). value. I have tried Jul 13, 2016 · I want to get parent's element offset in angularjs. onclick = function(e) { // e = Mouse click event. Dec 22, 2015 · I am trying to get the top offset of a div, and I have the following code that gets run when the page gets scrolled: Get offset(). dropdown"). element(this). Aug 4, 2012 · window. top of element from the top of Apr 21, 2019 · is a measurement which includes the element borders, the element vertical padding, the element horizontal scrollbar (if present, if rendered) and the element CSS height. In other words, these properties of the element are taken into account: padding-top; border-top; scroll-margin-top (and not margin-top) In addition, if the html element has scroll-padding-top set, then that is taken into account too. scrollTop = whatever; },1) Jul 10, 2024 · a containing block for absolutely-positioned elements; an element with a different effective zoom value (that is, the product of all zoom scales of its parents) from this element; td, th, table in case the element itself is static positioned. This is pretty easily accomplished using element. See How to get an element's top position relative to the browser's window? for how to get the scroll position. getElementById('test'); //get the distance scrolled on body (by default can be changed) var distanceScrolled = document. If the element isn't scrolled at all up or down, then scrollTop is 0. Sep 27, 2021 · I have this element that I'm referencing by Id: let infiniteScrollElement = document. So how can I get jQuery object of current scope element? Or, if I've chosen the wrong way Angular is a platform for building mobile and desktop web applications. css('top','current position'); And If you need the ElementRef of a component, you can't use a template variable. Sep 11, 2024 · A double-precision floating-point value indicating the number of pixels by which the element is currently scrolled vertically from the origin, where a positive value means the element is scrolled down (to reveal more content to the bottom). scrollTop function to get the height you already scrolled if you want to get the position relative to the page. link. top; // now we will calculate according to the current document, this current // document might be same as the document of target Oct 10, 2017 · You don't need angular. top; So I would change your code to: template Aug 5, 2015 · How to watch offset top position (of each element) and if the distance to top screen border lower than 100 px, i need to hide this div. The Oct 15, 2014 · Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand Jul 13, 2010 · document. Note: The offsetParent element is the nearest ancestor that has a position other than static. The left, top, right, bottom, x, y, width, and height properties describe the position and size of the overall rectangle in pixels. So far everything is working except that I don't now how to get the initial position of the HTML element when I click on it and want to start moving. getBoundingClientRect() method that returns a DOMRect object which is the smallest rectangle which contains the entire element, including its padding and border-width. ts May 12, 2013 · This function takes one argument, which is the element wrapped with jqLite. Import Necessary Modules Definition and Usage. top; For your information, in Angular I am using template variable with @ViewChild, but the topOffset value got changed and is not giving the same required result as like jQuery. getBoundingClientRect(); var x = e. slider-horizontal { width: 210px; height: 20px; } import {Component, OnInit, Input, ViewChild, ElementRef, Renderer} from Mar 19, 2014 · and checkPos is a function on the scope which checks the element offset top and left to see what quadrant it is on the webpage. If you need the offset of the element in respect to the whole body it may get more tricky, as you will have to sum the offsets of each element in the chain. Dec 21, 2014 · I'm trying to refactor out all my jQuery with pure Javascript, I got everything working except a very specific value. So let's say I have a list of orders called "orders" Mar 8, 2012 · Trying to make the browser scroll to a specific ID with an added offset - $('html, body'). First, modify the element that matches the specified ID to include a template reference variable for the target element. I have used angular. to select an element you can use querySelector() that returns first matching element or querySelectorAll() that return all matching element . When I'm scrolling down it grows up when scrolling up the offset top value decreses. child. Aug 31, 2023 · Use the template variable to inject the element into component class using the ViewChild or ViewChildren. Jul 29, 2024 · The returned value is a DOMRect object which is the smallest rectangle which contains the entire element, including its padding and border-width. After checking DOM and styles in browser I discovered that is because of two CSS elements. setTimeout(()=>{ this. Something similar has been done with jquery already but I want same with Angular. One is: . top gives on fixed element current position from the document top. Set element height from another element in Angular2. element"). 1 Angular get offset of element by id. top}, 'slow'); What I need to do is to set the offset by -100p May 2, 2023 · You can use . I use angular and get the element using a template reference in the component. You see, the top of the page has a header that 'fades into' the rest of the page. Templates. The next step is to make the position > offset be setted from an @Input(). top Jul 24, 2012 · I did it like this in Internet Explorer. So for each of innerItems I'd like to call jQuery . Is there a way to get the offset in the Mar 26, 2012 · I'm trying to get the position of an element within the window like so: var link = $(element); var offset = link. Like x= 10 and y = 30 for example. 0. After I load and display the messages I want to scroll down in the window so the user can see the latest messages. Nov 30, 2014 · To fix your ul to the top when it hits the top of the page on scroll, you can put a directive on it that checks for the window's scrollTop() exceeding the ul element's offset top. getBoundingClientRect(); //get the offset from the element to the viewport var elemViewportOffset = elemRect. But that does calculate with document height, not with the view-port height. top; var left = offset. Called after the ngAfterViewInit() and every subsequent ngAfterContentChecked() So code looks like this: Aug 30, 2017 · I am trying to get the width of an element using JS in my Angular app. scrollContainer. prop('offsetLeft'); or if your "this" is valid dom element. offsetTop read-only property returns the distance from the outer border of the current element (including its margin) to the top padding edge of the offsetParent, the closest positioned ancestor element. Apr 7, 2016 · Use case: On scroll I want to be able to change classes of various elements on the page based upon where I am. this. top; Alternative to @HostListener and scroll output on the element I would suggest using fromEvent from RxJS since you can chain it with filter() and distinctUntilChanges() and can easily skip flood of potentially redundant events (and change detections). how can i do it? Actually i can find the window offset of an element but it retrieves the coordinates from the border of the element like this: var _position = $(this). But how do I get styles of an element (ie, the default styles as rendered by the browser)? This code doesn't work but expresses what I'm trying to do: <p>TEXT</p> width of TEXT element is {{textElement. Any ideas how to achieve this in angularjs? Jan 31, 2019 · Hi I need to be able to drag and drop some html elements but I need to know the end position of the drop. getElementById('th-infinite-scroll-tracker'); I need to listen when the browser is has reached the bottom May 14, 2020 · You can set read metadata rroperties to ElementRef to get offset of child element. renderer. scrollIntoView( { be May 19, 2017 · I know you can use ngStyle to set styles of an element. Can someone explain how I can get an element's position? elemen Jul 10, 2018 · Sometimes the Angular change detector is weird about picking up changes to the native DOM and as a workaround you can escape the change outside the regular angular event loop with a timeout. top and both return 0 the parent elements also return 0 as their offset top. top; const elementPosition = elementRect - bodyRect; const Jun 11, 2014 · // elementScroll = element[0]. So, inside this method use a flag (or counter) and setTimeOut: May 11, 2022 · I want to get id of the section element when it reaches the top. scrollTop; //create viewport offset object var elemRect = elem. Dec 11, 2018 · This is working fine. var viewportOffset = el. Sep 15, 2010 · function getWindowRelativeOffset(parentWindow, elem) { var offset = { left : 0, top : 0 }; // relative to the target field's document offset. offset() returns an object containing the properties top and left. top; // now we will calculate according to the current document, this current // document might be same as the document of target field or it may be // parent of the Oct 20, 2018 · So I tried making a chatbox window component that displays all the messages. Nov 24, 2015 · Use . element() has all the jQuery function built-in? Jul 12, 2019 · AngularJS - How to get offset of top and left position of an element in document. offset() to get the distance between an element and the top of the document: angular. 6 (in IE and Chrome, the two values match). or a function that returns the top offset position Mar 6, 2015 · I am trying to make sure the page scrolls to an element when a certain span is clicked. activeElement" is executed just after the focus change, you get the whole body since while entering the new element the active element is indeed the document/body itself. offsetWidth; When I do this i am getting the below compilation error Jan 9, 2017 · I shouldn't use jQuery in my application but I got a scenario where I needed the offset of the element for which instead of using $(element). element(document. scrollIntoView() but I need to set an offset. NgIf: A structural directive that conditionally includes a template based on the value of an expression coerced to Boolean. offsetTop = document. offset() is more useful. I've tried simply putting the var instead of the 100 like this: [position]= "{ my: 'left top', at: 'left top', offset: '0 offsetY'}" but the popup stick at 0 0 even tho offsetY = 150. I tried using element. This takes many elements from previous answers and combines into a tiny (194 bytes minified) anonymous jQuery function. Jul 30, 2018 · The reason you wouldn't just subtract outer top from inner top in the first place and ignore the scroll position is because on the off chance that you are scrolling while the calculations take place you could throw off the offset, as getBoundingClientRect() only takes into account the distance from the edge of your view to the element, while Jan 9, 2015 · I have the following row: &lt;tr ng-click="show()" ng-repeat="lim in limit"&gt; I need to get the offset (i will need Top and Left in px) of this tr. top is actually giving me a decimal value in FFX 3. You have Inject ElementRef service inside Child component so that you can child component nativeElement Inside parent component. animate({scrollTop: $('#contact'). left = elem. Problem is that jQuery. Jan 14, 2009 · The correct approach is to use element. Here's a browser compatibility table taken from the linked MDN site: Aug 12, 2015 · I have a directive, and I simply want to get its size/position or the size/position of its containing element. menuStickyElement. getElementsByClassName("element")[0]. element(element). offset() is supposed to provide an abstraction for this to provide the correct value xbrowser. Apr 20, 2013 · I want this view to have the same offsetTop as the item. Dynamically change CSS style height. top Mar 19, 2021 · The next step is to calculate the top offset of the HTML element depending on the window. Jun 28, 2017 · I need to get the offsetHeight of the content &lt;div&gt; defined in the parent component (base layout) from my child component, so I can make another &lt;div&gt; with the same size. getBoundingClientRect() from Chrome's console I get proper result with actual values in the properties. prop('offsetLeft'); Example Oct 13, 2017 · I think this should get you most of the way there: // Position of first element relative to container top var scrollTop = $(". Any help will be appreciated. jQuery detect div location on scroll. @param offset [number, number] | (() => [number, number]) A position in screen coordinates (a tuple with x and y values) or a function that returns the top offset position. Mar 5, 2017 · I have a template that creates a list of links using *ngFor and a separate div element that I want to change its location based on the currently active link. See Also: The offsetLeft Property. May 18, 2013 · The returned value is a TextRectangle object, which contains read-only left, top, right and bottom properties describing the border-box, in pixels, with the top-left relative to the top-left of the viewport. I know how to do this in jQuery, however cannot find a solution in pure angularjs. I try to get information about parentElement. Commented Jun 28, Angular 2: Get position of HTML element. The web development framework for building modern apps. The project I'm working on needs to get the offsetTop value of several DOM element when the page just loaded. querySelector('yourelement')). I tried like I'm trying to implement a custom directive in Angular 2 for moving an arbitrary HTML element around. element(("li . We will look at example of how to get div height and width in angular. Then i drag the position and get the positions x=10 and y=30. Jun 19, 2019 · I've tried to get offset data of the component in my angular app as below. A template variable only returns ElementRef for plain HTML elements. Help please write Angular directive. Oct 31, 2023 · The HTMLElement. scrollY; var leftPos = element. querySelector('#first'). top = angular. Respectively for . var rect = e. What is going on here? It seems like I'm getting the location relative to the parent instead of the document. px of another div to make it scrollable on content overflow-y. In the following code, the overlay element is shifted 50 pixels to the right and 25 pixels up. el. activeElement; }); Dec 16, 2020 · I have a component which is manually resized so I've added a listener: @HostListener('window:resize') public detectResize(): void { // get height and width of the component this. width vs. Nov 22, 2018 · Angular 2 get element height. And our element was 2000+ pixels down from the current viewport. getBoundingClientRect is also worth a look. What I am trying to do is get the coordinates of where an element was clicked relative to the top-left of the element. The offsetTop property returns the top position (in pixels) relative to the top of the offsetParent element. jQuery. top, distance = (elementOffset - scrollTop); Dec 11, 2015 · You can just use a timeout: setTimeout(function() { // Your delayed code goes here }); Without specifying a delay as a second parameter, the passed function will be called immediately after the curren thread of execution that finishes with rendering of the page. view-main-screen[_ngcontent-aer-1]{} and second one is element{}. animate(targetPosition) it is working properly so I wanted to know whether angular. First row about parentElement has offsetTop like 385. log element I can see the offset top is -55 which is correct, the element is off the screen by approximately 55 pixels. What's the best way to get the position of those td's in the table so I can position the other elements? I'm currently trying to use something like Jun 28, 2017 · Am looking for the position of the element "offset from the top of the window/document" – Rolando. getBoundingClientRect(). Like first of all element A was on position x=5 and y=5. reference. var rect = element. top = elem. element('#feed-details'). offset() method that gives me left/top values from the top-left corner of page. Now I need the same behavior in Angular 4, but I'm something missing, my offset top value is still the same. My problem is when I try to get height it is null, but when I set some height by setStyle() and then I get it by getStyle() it returns proper value. To get the DOM element hosting the component/directive. getElementById('targetElement'); const offset = 45; const bodyRect = document. getElementsByClassName('_full')[0]. Sep 19, 2014 · If you really want to get the offset relative to its parent, you could substract the offset of the parent. offsetWidth But it is returning 0 if I don't pass it's css property as below. nativeElement. theHeight Now, in the same click callback function If I try to get element-1 as $('. I try to using parentElement. e. let’s discuss about angular get element width. height}} Aug 27, 2019 · Please don't mark this as duplicate, I have searched and searched and couldn't find a solution. So just put the current screen top position to: $('#content'). Also you need to add a listener to window scroll event if you want to get these values while you scroll: May 11, 2022 · I need to get the offsetHeight of a div in order to set the max-height. You can see this in your dev tools on this page: document. offsetWidth – Sep 19, 2015 · You may be encouraged to use the Element. Aug 2, 2017 · In jQuery element. offset() which will give you position of element & can provide top & left position. I'm binding to the top and left styles of my HTML element with those two host bindings: var element = document. Why the difference and what can I do to get the actual value from my Problem: I Cannot get correct top offset value of DOM element when page just loaded. So I need to check the element's y position. setStyle(this. element for this. Oct 19, 2017 · This is supposed to be very simple, I have a certain element in my component template that I want to scroll down to it smoothly after the page finishes loading if it is passed in the url as a fragment like this: '. Adjust fixedElementHeight for the height of your menu or blocking element. hei Jan 20, 2020 · the rectViewport is our element el and utilizing getBoundingClientRect() the top is the combination of the el's viewport top and scroll top; Let's imagine we were scrolled down 200ish pixels, we would see scrollTop to match that. getElementsByTagName('bs-datepicker-container'); and then if I where to console. documentElement. How would I get the the absoulute position or relative to the document of the top and left offset position for 'div Sep 2, 2016 · I have problems calculating the offset top of the element relative to the tree-view componentcause I have a treenode elementRef and I try to go on it's parents but when he reach the final treenode in the tree structure the parentElement is null. Try this: @ViewChildren('Children',{read:ElementRef}) Children: QueryList<ElementRef>; Or. using the cdkDrag directive I see from the docs that there's an event cdkDragEnded. id). ngAfterViewInit() { let height = this. offset(); Feb 27, 2018 · You can use the following approach. I am able to get the same using ngAfterContentChecked. getElementById('clickme'). target. The element's border-box position is specified relative to the document. I tried in similar way but not getting success. You could also use the . (each div can move on page). active"). Tip: To return the left position of an element, use the offsetLeft property. Simultaneously, create a duplicate of the element without a template reference variable for those elements that do not match the specified ID. /componentPath#someElement' I tried to do it by adding a #someElement to the element in html and then used Jun 15, 2021 · Im working in a menu where the current section is gonna be select it on scroll, but when i try to get the offsetTop of the elements i get alway 0 for some reason, on the parentElement a get value for offsetTop but in this case does not work for me using the offsetTop of the parentElement because i have many childElements inside with different Oct 6, 2016 · For those who want to get height and width of device even when the display is resized (dynamically & in real-time): . Check the John Resig's post describing how helpful this method is. Fortunately, the Angular E2E DSL has a passthrough method for Jan 26, 2017 · If #myanchor is on a component or directive instead of a plain DOM element, you need to add read to get the ElementRef @ViewChildren('myanchor', {read: ElementRef}) anchors: QueryList<ElementRef>; See also angular 2 / typescript : get hold of an element in the template Mar 1, 2015 · You can use the jQuery's filter function to filter elements based on their offset. top + window. . 3. position(), which retrieves the current position relative to the offset parent. getElementById('myElement'); var topPos = element. css('margin-top', top); This has no effect. Detect first top element when scrolling. document. Ask Question Asked 4 years, 1 month ago. addEventListener('load', function() { //get the element var elem = document. prop('offsetTop'); angular. top Now if you scroll down, so that the element almost touches the top of the window, you get 70 for the same exact same elmenent Dec 6, 2013 · I am using a table with a link column when the link is clicked i would like to get the offset of the row. activeElement; }); Edit für ES6 (where "this" also can be used): setTimeout(() => { X = document. I can't watch each element top offset. left; offset. In Angular (including Angular 2+), you can get the offsetTop of an element without using jQuery by accessing the native DOM element properties. May 7, 2018 · I need to get the offsetTop of an alement that does not have an ID so I am getting the selectors by name: const element = document. clientX - rect. top; //add them In an angular 5 component I have a table, and I need to create something like overlaying multiple divs above several td's. offset(); var top = offset. After that i want use them to update the position of the element next time. getBoundingClientRect(), but it return 0, too. scrollIntoView() function in JavaScript. Here's how you can achieve this: Method 1: Using ElementRef and ViewChild. body. function getElementByTopOffset(selector, offset){ return $(selector). This method is called after every change detection run. Contrast this with . scrollX; That allows me to get the real relative position of element on document, even if it has been scrolled. The problem is that when I get the offsetHeight of the div, it has not completed the rendering and therefore returns 0 the first time. the window var top = viewportOffset. This is what I tried so far. If no offset parent exists, the offset is relative to the document body. getElementsByTagName, as each object in the DOM has these attributes. function getWindowRelativeOffset(parentWindow, elem) { var offset = { left : 0, top : 0 }; // relative to the target field's document offset. Looking in the doc & forum of Sep 1, 2021 · // get the top offset of the dropdown (distance from top of the page) var topOffset = $(". getBoundingClientRect() method to get the top offset of your element. offsetTop is what you're looking for. How to scroll to an element in JavaScript? The . I have searched for hours, so please don't downgrade me! Sep 2, 2020 · I have a problem: I want to get the position of an element as values. May 13, 2019 · This SO question How to get an element's top position relative to the browser's viewport has a better way to get the element position, var viewportOffset = el. Angular: How to change child element They return the offset from the parent element. offset() setter method allows us to reposition an element. filter(function( index, elem) { return $(elem). elementView. Ask for ElementRef in the constructor (Angular Dependency injection), the Angular will inject the reference element hosting the component/directive. When the expression evaluates to true, Angular renders the template provided in a then clause, and when false or null, Angular renders the template provided in an optional else clause. element-1'), I am not getting that element because it might not in the DOM immediately when the isShown = true. scrollTop >= this. width}} height of TEXT element is {{textElement. Note: If you want to manipulate the DOM elements use the Renderer2 API instead of accessing the elements directly. Step 1: In that Component do: import { HostListener } from "@angular/core"; May 2, 2024 · Now, let's see post of angular get element width and height. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), . Mar 30, 2021 · In the "Basic Drag&Drop" section, if you get elements' Y position without scrolling the page, you get 626 for element. So, how can I get the element by not using Jul 31, 2022 · I am trying to scroll elements into view using the . Jquery Get Element's Top Offset While Scrolling. How to get width of (DOM) Element in Angular 4 after page is loaded. section. The variable is called offsetY. offset(). left; var bottom = $(window). But when I check parentElement. nativeElement, 'position', 'fixed'); Jun 17, 2016 · Inside the show() method I am trying to get the result of getBoundingClientRect() but its returning 0 for all properties but when I type in document. offsetHeight } make sure yo do this after the size of the element was set (ngAfterViewInit()). In a previous version of angular it was somewhat possible through a plugin (same for jQuery). getBoundingClientRect(); // these are relative to the viewport, i. The offsetWidth Property. style. I'm getting a different value depending in the browser vendor for this code : Jul 11, 2017 · However when I get the element in code and check offsetLeft the value is 3 and offsetTop is 16. If the element is a component, you'll get the component instance instead. const element = document. offsetTop and $(element). The way as I see it — on ng-mouseover I call the function that sets left/top properties to my absolutely positioned popup. If you absolutely insist this must be done with angular, well, angular simply leverages jqLite via angular. 2. Apr 15, 2021 · I used the approach outlined here and implemented it to get this working as intended. How cant I get parent's element offset? Dec 2, 2020 · Angular viewChild get offset width. getBoundingClientRect():. We use the . But ngAfterContentChecked called many times. Jan 8, 2014 · I am writing an end-to-end test in Angular, and I would like to verify the position of a DOM element in relation to another DOM element. offsetTop like second row, it return only 0. container . Mar 9, 2016 · import { Component, OnInit, HostListener, ViewChild } from '@angular/core'; @ViewChild("pageMenu") menuStickyElement; @HostListener("window:scroll", []) sticklyMenu() { // Get top height this. scrollTop(), elementOffset = $('#my-element'). bottom, rect. scrollTop if (document. getElementById("temp"). I am not sure how to identify the element that the ng-class is in, so that I can start checking values. left + window. Jan 17, 2017 · I have a Component which update css class . component. All block-level elements report offsets relative to the offset parent: offsetTop; offsetLeft; offsetWidth; offsetHeight; The offset parent is the nearest ancestor that has a position other than static. Oct 2, 2016 · If you has under a *ngIf="condition" and the condition is not fullfilled, Angular can found it. log(rect. We can combine to get 2200+ of the actual window. offset() -> Object {top: 0, left: 0} Nov 14, 2017 · If an element doesn't have a width applied to it via a style tag or css, it will return empty and not the actual width of the element. html Oct 15, 2018 · When im trying to set the offset or top style, I get the same error: ERROR TypeError: Cannot assign to read only property 'offsetTop' of object '[object Jan 22, 2018 · Getting element position from the top of scrolled container div in Angularjs directive 0 Angular: How to get the offset height of an element after full rendering? Nov 24, 2016 · Access the element in the ngAfterViewInit lifecycle hook. Reading scroll offsets. A try-catch block is added in the beginning to use the offset() of jQuery if jQuery is included. The Jan 28, 2015 · looking for guru help, I'm using angularJS in a repeating list in the code below. In my directive, which is rendered in a ui-router view, I've attached a controller, and when I try to get the size, however, it's always zero. setTimeout(function() { X = document. offset() and also for animation I am using like angular. position() -> Object {top: 0, left: 0} element. element jqLite is a tiny, API-compatible subset of jQuery that allows AngularJS to manipulate the DOM in a cross-browser compatible way. Permitting direct access to the DOM can make your application more vulnerable to XSS attacks Aug 10, 2011 · jquery how to get the page's current screen top position? If I scroll my mouse wheel to some part of the page, how do I get the page's current top position? I want click one element in my page, then open a div which top is to current screen top. Jun 26, 2015 · One requirement that has been passed to me is that when a form is invalid and the user clicks submit, the window should scroll the first invalid element into view. top - this does not work undefined? // logic follows that if elementScroll is between windowScroll & windowScroll + windowHeight it is visible! }); I just can't seem to get the x and y positions for my specific element (the directive may be repeated many times). document. A positive offset shifts the element to the right or down; a negative offset shifts it to the left or up. left i would like to retrieve the element offset starting from his own x center coordinates. If your condition is false and makes the condition true but you don't wait Angular "repaint", Angular can not find it -typical you enclosed in a setTimeout() to give time Angular "repaint"-– Dec 20, 2014 · You can use prop() from angular jqlite. top == offset; }); } Also if you fancy doing in completely vanilla here could be a solution: Mar 19, 2019 · As Angular documentation says: Respond after Angular checks the component's views and child views / the view that a directive is in. This method provides the full offset values (left, top, right, bottom, width, height) of your element in the viewport. 20 Jan 30, 2016 · Basically you could use two options to get top position of desired element. eg. element. left; //x Jan 16, 2017 · In order to get correct offset values you can use: ngAfterContentChecked with the AfterContentChecked Interface. dropdown. angular. element('#user'+user. vgrd taasf zzuxf vrgulvf zssbs jmk ehmo hjyd sbyhel zqvh jsnxrwu kyyd yfaehmv idhcy wiwpevhdk