How would you control size of an element on resize of the window in a component?



How would you control size of an element on resize of the window in a component?..

Answer / 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

More AngularJS Interview Questions

What is angular good for?

1 Answers  


Can you explain to $on and/or $watch ?

1 Answers  


Can angular run without node?

1 Answers  


What are differences between angular 4 and angular 2?

1 Answers  


Explain webpack?

1 Answers  


What is a component angular?

1 Answers  


What is the use of a filter in angularjs?

1 Answers  


Explain data binding in angular 4?

1 Answers  


Write all the steps to configure an angular app(ng-app).

1 Answers  


How to load select box during page initialization using AngularJS?

1 Answers  


What is route snapshot?

1 Answers  


What is the use of interceptors in angular 4?

1 Answers  


Categories