Home > Web Front-end > JS Tutorial > Angular2 page size changes

Angular2 page size changes

小云云
Release: 2018-01-26 13:13:11
Original
1570 people have browsed it

1. Phenomenon

Charts in full-screen pages often need to be resized to adapt to page size changes. This article mainly introduces the solution for Angular2 to monitor page size changes. Friends who need it You can refer to it, I hope it can help everyone.

2. Solution

1. Introduction:

import { Observable } from 'rxjs';
Copy after login

2. Use (in ngOnInit method):

ngOnInit() {
  // 页面监听
  Observable.fromEvent(window, 'resize')
   .debounceTime(100) // 以免频繁处理
   .subscribe((event) => {
    // 这里处理页面变化时的操作
    console.log('come on ..');
   });
}
Copy after login

3. Summary

Research whether there are more ways to log out these monitors when switching? To avoid memory leaks. Whenever possible, in the ngOnDestroy() method.

Related recommendations:

A simple way to build an angular2.0 project

Detailed examples of how Angular2 integrates other plug-ins

How to get nodes in angular2

The above is the detailed content of Angular2 page size changes. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template