How would you control size of an element on resize of the window in a component?
Answer Posted / Shikha Rai
To control the size of an element on window resize in Angular 2, you can use the following approach:
1. Import the EventListener from @angular/core and declare it as a property in your component class.
2. Add the EventListener to the window object's 'resize' event using the nativeWindow.addEventListener() method.
3. Inside the resize event handler, calculate the new size of the element based on the current window dimensions.
4. Update the element's style or properties with the calculated values.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Give the example of angularjs strings?
What is the latest angular?
How to use primeng in angular 4?
Angularjs dependency injection of value inside of the module.config?
How to enable html5 mode in angular 1.x?
How to get and log an error in angular 4?
How to create angularjs filter which outputs html?
Which version you are using js?
How to implement a datagrid table with angular 2 and primeng?
What is the latest version of angular?
How an object or function can get a hold of its dependencies?
How can primeng be used with angular2?
What is a dynamic route in angularjs and how do you implement it?