检查用户是否在没有jQuery的情况下在Angular2中滚动到页面底部的最佳做法是什么? 我有权访问我的应用程序组件中的窗口吗? 如果不是,我应该检查滚动到页脚组件的底部,我该怎么做? 页脚组件上的指令? 有没有人完成这个?
What is the best practice to check if user has scrolled to the bottom of the page in Angular2 without jQuery? Do I have access to the window in my app component? If not should i check for scrolling to the bottom of the footer component, and how would I do that? A directive on the footer component? Has anyone accomplished this?
最满意答案
//你可以使用这个。
@HostListener("window:scroll", []) onScroll(): void { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // you're at the bottom of the page } }// You can use this.
@HostListener("window:scroll", []) onScroll(): void { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // you're at the bottom of the page } }检查用户是否滚动到Angular 2的底部(Check if user has scrolled to the bottom in Angular 2)检查用户是否在没有jQuery的情况下在Angular2中滚动到页面底部的最佳做法是什么? 我有权访问我的应用程序组件中的窗口吗? 如果不是,我应该检查滚动到页脚组件的底部,我该怎么做? 页脚组件上的指令? 有没有人完成这个?
What is the best practice to check if user has scrolled to the bottom of the page in Angular2 without jQuery? Do I have access to the window in my app component? If not should i check for scrolling to the bottom of the footer component, and how would I do that? A directive on the footer component? Has anyone accomplished this?
最满意答案
//你可以使用这个。
@HostListener("window:scroll", []) onScroll(): void { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // you're at the bottom of the page } }// You can use this.
@HostListener("window:scroll", []) onScroll(): void { if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) { // you're at the bottom of the page } }
发布评论